Jump to content

Add To Cart Link From Non Ps Site?


Recommended Posts

Hi everyone,

 

I'm at my wits end trying to solve a problem and hope that maybe someone knows a fix.

 

I'm finishing a site that has side by side installations of WordPress and PrestaShop 1.6.1. WP is on one subdirectory (/site) but set to show at the root; PS is in another subdirectory (/store). Each application has its own database.

 

I've been trying to find a way to let users add items to cart from the WP side of things and am running into what I believe to be cookie or session issues. The link I've used (domain.com/store/cart?add=1&id_product=30) will not add an item to the cart on the first click through--it goes to the store homepage instead--but will on subsequent clicks. I've searched the forums here to make sure my syntax is correct, turned pretty urls on and off, and I've also tried adding in the recommended code in the documentation (http://doc.prestashop.com/display/PS16/Managing+Cookies) to my WP header to see if I can get it to work. None of these steps do.

 

Does anyone know of a better link I should use, code I should plug into WP, or module I should purchase that will allow me to do this simply? Surely I'm not the only person looking to publish a working "Add to Cart" link from a non-PS page.

 

I appreciate any help you can offer.

 

Thanks,
Meagan

 

 

 

Link to comment
Share on other sites

Below are the normal variables that are sent when adding a product to the cart using ajax. 

controller:cart
add:1
ajax:true
qty:1
id_product:2
token:00fc6d25b92e20240701ff1d77c83203
ipa:7

You can ignore ajax, ipa and qty, however the others would be required.  I think what is missing from your URL is the token.  Prestashop checks that a valid token is sent, and if not present or valid, will not process the request

 

I tested the following on a local 1.6 store, and it did work properly.

domain.com/store/index.php?controller=cart&add=1&id_product=2&token=00fc6d25b92e20240701ff1d77c83203
 

Link to comment
Share on other sites

Hi, I've tried this code with both the sample token as well as the one that appends within my site and I still have the same problem: Nothing in cart on first click, and everything works fine after that. Is there anything else I should try? I appreciate any ideas you have. Thanks, Meagan

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...