From cd5326c997d944ad7fdc6f7108612b7ed4c3d606 Mon Sep 17 00:00:00 2001 From: Stephen Pankratz-Brown Date: Tue, 19 Apr 2016 13:35:55 -0400 Subject: [PATCH] Use isUpdating bool to prevent additional ajax cart requests until cart is updated and ready for more. --- assets/ajax-cart.js.liquid | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/assets/ajax-cart.js.liquid b/assets/ajax-cart.js.liquid index c003ae000..63edac389 100644 --- a/assets/ajax-cart.js.liquid +++ b/assets/ajax-cart.js.liquid @@ -333,6 +333,10 @@ var ajaxCart = (function(module, $) { // Add or remove from the quantity $body.on('click', '.ajaxcart__qty-adjust', function() { + if (isUpdating) { + return; + } + var $el = $(this), line = $el.data('line'), $qtySelector = $el.siblings('.ajaxcart__qty-num'), @@ -359,6 +363,10 @@ var ajaxCart = (function(module, $) { // Update quantity based on input on change $body.on('change', '.ajaxcart__qty-num', function() { + if (isUpdating) { + return; + } + var $el = $(this), line = $el.data('line'), qty = parseInt($el.val().replace(/\D/g, '')); @@ -412,13 +420,12 @@ var ajaxCart = (function(module, $) { }; adjustCartCallback = function (cart) { - isUpdating = false; - // Update quantity and price updateCountPrice(cart); // Reprint cart on short timeout so you don't see the content being removed setTimeout(function() { + isUpdating = false; ShopifyAPI.getCart(buildCart); }, 150) };