Skip to content

Commit

Permalink
Merge pull request Shopify#530 from Shopify/fix-ajax-cart-request
Browse files Browse the repository at this point in the history
Fix ajax cart request
  • Loading branch information
Stephen Pankratz-Brown committed Apr 19, 2016
2 parents d123269 + cd5326c commit 91bb393
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions assets/ajax-cart.js.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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, ''));
Expand Down Expand Up @@ -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)
};
Expand Down

0 comments on commit 91bb393

Please sign in to comment.