2
votes

Is there a way to add multiple products to the shopify cart and one time and also collect line item properties or customizr variants for these products? Either using the AJAX API or the POST form method.

My client sells 1000's of tennis racquets which all have string options (the same for each racket), even if we wanted to do a massive amount of data adding these variants for each product the products we max out at the 100 variant permutation per-product. My work around is to add the string option as an extra item to the cart (the ajax api will work), but I also need to collect some other option data. Is there documentation on using the ajax api to add items with "line item properties" ?? I know this feature was just added this summer.

Thanks!!

1

1 Answers

5
votes

The Ajax call to Shopify is /cart/add.js. If you include the data for the properties, you will see that it works. I use it all the time, although in this example, it's hardcoded. The following works for me. Obviously you can hotrod this to your needs.

addItem: function(variant_id, quantity, callback) {
  var quantity = quantity || 1;
  var params = {
    type: 'POST',
    url: '/cart/add.js',
    data: 'quantity=' + quantity + '&id=' + variant_id + "&properties[foo]=fizzbuzz",
    dataType: 'json',
    success: function(line_item) {},
    error: function(xhr, status) {}
  };
  $.ajax(params);
},