Jump to content

Link to cart with product add


pawelo

Recommended Posts

Hi,

 

is it possible to create a link which add product to cart and automatically redirect user to order page?

 

I want to use that link in other web page, and after user click on it, he should landing in shop order page with product already added into cart.

Link to comment
Share on other sites

I'm afraid it's not possible to achieve what you are looking for without custom development.

 

For not logged in customers there is possibility to use a direct link to add to cart with a url like this:

YOUR_SITE/index.php?controller=cart&add&id_product=10&qty=1

 

For logged in customers there must be a token parameter in the url

YOUR_SITE/index.php?controller=cart&add&id_product=10&qty=1&token=8522548b65fc6d65485e47efa300698c

 

Token is generated depending on customer id and password. See file classes/Tools.php, function getToken.

 

And another limitation is that add to cart only works if there is already a prestashop cookie created for a visitor, as the code comments say. to prevent bots from creating carts. See file controllers/front/CartController.php.

 

So for the first time visitors, coming from the direct add to cart url, the product would not be added to the cart.

 

Anyway, please make your own tests and see how it goes.

Edited by pishkus (see edit history)
Link to comment
Share on other sites

  • 4 months later...

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...