Created
May 3, 2018 02:48
-
-
Save bjornbennett/695db8f004caa574e7ca1f2035259471 to your computer and use it in GitHub Desktop.
Shopify Liquid / jQuery - Get cart item count
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
// on anchor click, after 300ms, fetch cart count. | |
$('a').click(function(){ | |
setTimeout(function(){ | |
$.getJSON('/cart.js', function(cart){ | |
var result = cart.item_count; | |
console.log(result); | |
}); | |
},300); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm not sure why you're getting an error for cart.json, although the code sends an AJAX request to cart.js. Are you sending an AJAX request to cart.json instead? Typo maybe? I just tried it again on the link above and it appears to still be functional.