Jump to content

Add a second product to cart automatically


boulio971
 Share

Recommended Posts

Hello,

 

I am using PS 1.6.0.14

 

I modified the ajax-cart.js file in order to add 2 products in the cart when the user click on "add to cart" button

 

[Workflow]

- User is on the product page of Product1 and click on "Add to cart"

=> Product2 is automatically added also to the cart

=> This order should be resoected : Product1 is added then Product2

 

So I modified the ajax-cart.js file like this :

 

ajaxCart.add(idProduct1, $('#idCombination').val(), true, null, $('#quantity_wanted').val(),null) ;
ajaxCart.add(idProduct2, $('#idCombination').val(), true, null, $('#quantity_wanted').val(),null) ;

 

Results are the following :

- Sometimes it works as expected

- Sometimes no products are added to the cart (rarely)

- Sometimes just one of the 2 products is added to the cart (randomly)

 

I think that this behaviour is because of the 2 calls of the add() function which will run ajax request

 

But I don't know how to solve this pb and have a reliable behaviour as described in the workflow

 

Could anyone help me please ?

 

Thanks

 

Larry

Edited by boulio971 (see edit history)

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More