Skip to content

Instantly share code, notes, and snippets.

@kyleaparker
Last active December 27, 2015 17:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleaparker/7360751 to your computer and use it in GitHub Desktop.
Save kyleaparker/7360751 to your computer and use it in GitHub Desktop.
Multi add to cart
{{ 'api.jquery.js' | shopify_asset_url | script_tag }}
<script type="text/javascript">
/* Enable multi add to cart function */
jQuery("#product-variants").hide();
Shopify.queue=[];$("#add").click(function(e){e.preventDefault();$(".quantity-add").each(function(){var a=$(this),id=a.attr('id'),qty=a.val();if(qty>0){Shopify.queue.push({variant_id:id,quantity_id:parseInt(qty,10)})}});if(Shopify.queue.length){Shopify.addItems()}else{alert("You have not selected anything to purchase")}});Shopify.addItems=function(){var request=Shopify.queue.shift();if(typeof request=='object'){Shopify.addItem(request.variant_id,request.quantity_id,Shopify.addItems)}else{document.location.href="/cart"}}
/* End multi add to cart function */
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment