Jump to content

How to: add two products at the same time with ajaxcart.add?


agshoward

Recommended Posts

Hi

 

Is it possible to have one ajaxcart.add call add two products from your catalog at the same time?

 

I can see how to make it work for one, but cannot work out what to do to add an additional product id so two differing products appear in the cart. My current method has issues and doesn;t always work.

 

thanks

Andre

Link to comment
Share on other sites

Hi,

 

You can make an override of the cartcontroller to do this, it works for me.

 

An other way would be to make a double call to ajaxcart.add but it would not be 'elegant'.

 

I perhaps missed the point, you want to add the same product 2 times, or one product plus an other ?

 

The first case is simplier, you can set qty=2 in ajax call.

 

Good luck

Edited by math_php (see edit history)
  • Like 1
Link to comment
Share on other sites

Thanks Math_PHP, that is the idea I want a different product to be added to the cart without the user having to select it. I'm using the double call today and it works but it not elegant as you say - also at times the additional or even original product never makes it to the cart.

 

How did you do the override? I have never looked at that so would be interested.

 

To give some context: I have a T-Shirt shop that has a jquery popup for selecting type of sayings and colours as well as whether front or back or both are printed. If the clients pick both sides I add an additional product from the catalog that is for customisation which also has a small fee associated with it. Once all the right selections are made the client saves the information and with using cookies I then add the respective items to the cart.

 

I have thought about packs, but I'm looking for my jquery popup to handle the multiple selections not the store itself.

 

thanks for any direction/input you can give.

 

Andre

Link to comment
Share on other sites

Hi Andre,

 

My override of CartController.php, is just an added function which detect if the product which is being added exist in Prestashop. If not the function create the product and give the id_product created to the standard 'add to cart' operations.

 

It can be a solution for you, but how are stored your product in prestashop ? You have t shirt xxl and then you have a color and an other product for the customisation.

It could work this way : in a modified ajax.add_to_cart you send the two or three product to add in one step.

 

Dont mind asking.

 

Good dev

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