Last active
December 27, 2015 17:19
-
-
Save kyleaparker/7360751 to your computer and use it in GitHub Desktop.
Multi add to cart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ '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