Shopify Cart Add js to add multiple products

JunaidT
New Member
5 0 0

I am facing an issue with adding multiple products to the cart using jquery ajax. I am getting multiple ids in the console. I tested the network tab as well and it is showing multiple add requests with a perfect status of 200 but when I refresh the page to view the cart it is showing 1 product and sometimes all get into the cart. I don't know why it is failing sometimes.

 

 $('.radio.selected').each(function( index ) {
  var The_id = $( this ).attr('datacustom_id');
     console.log(The_id);
jQuery.ajax({
  url:'/cart/add.js',
  type: 'post',
  dataType: 'json',
  data: { quantity:1, id: The_id }
  // Optional: success/error functions
})    
     
});   
0 Likes
JunaidT
New Member
5 0 0

Screenshot_100.png

 

2 requests with response 200 but some time it adds 2 product in cart and sometime only 1 is added

0 Likes