Eduvi Posted December 13, 2019 Share Posted December 13, 2019 First of all, sorry for my English. I found how to add multiple products into cart using AJAX, with registered users it works properly but I have some problems with "guest" users. I created this function. I call it for every product selected in the view, the id's and quantities I pass to this method are correct. function add_product_to_cart(id, qtt){ var token = prestashop.static_token; var actionURL = prestashop.urls.pages.cart; var query= 'controller=cart&add=1&ajax=true&token='+token+'&id_product='+ id +'&qty='+qtt+'&ajaxIdentifier='+ajaxIdentifier; jQuery.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, async: true, cache: false, data: query, success:function(result){ prestashop.emit('updateCart', { reason: result }); }, fail:function(resp){ prestashop.emit('handleError', { eventType: 'addProductToCart', resp: resp }); } }); } When I (as guest) add multiple products into the cart this way, it creates a cart for every different product I'm trying to add, but only happens the first time after I clean the cookies. After the first addition "guest" users can add the products as normal and uses the last cart created. I need to create just one cart and add all the selected products with its quantities to this cart. How can avoid this problem? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now