My site is: www.bellavirtuorganics.com. I have updated my site so that when on a collection page the user clicks add to cart it stays on the collection page. However, after making this change my cart counter does not work. I believe I need to add this code:
success: function(data){
var current_count = data.item_count;
$('.header-cart-count').html(current_count);
}
But I’m not sure where to put it? It seems like if I add the code, it prevents my ‘stay on collections page’ function from working. Here’s my Ajaxify-cart.liquid code, thanks for your help!
{% comment %}
If you want to animate your feedback message.
{% endcomment %}
Finally found a solution to the header cart icon not updating after adding to cart on the debut theme.
in the following section of ajaxify-cart.liquid
if (_config.cartCountSelector && $(_config.cartCountSelector).length()) {
var value = $(_config.cartCountSelector).html() || '0';
$(_config.cartCountSelector).html(value.replace(/[0-9]+/,cart.item_count)).removeClass('hidden-count');
}
if (_config.cartTotalSelector && $(_config.cartTotalSelector).length()) {
remove the following
&& $(_config.cartCountSelector).length()
so that section now reads
if (_config.cartCountSelector) {
var value = $(_config.cartCountSelector).html() || '0';
$(_config.cartCountSelector).html(value.replace(/[0-9]+/,cart.item_count)).removeClass('hidden-count');
}
if (_config.cartTotalSelector) {
looks like there is an error with the .length function.
Hi, I have the same issue on my debut theme that my cart does not count. I have carefully read this solution but in my ajaxify liquid file this code does not axactly the same way you have written.
Here I will copy and paste my code. Where should I change could you please describe me again?
Sorry for asking the same question again. I would appreciate if you could review.
{% comment %}
If you want to animate your feedback message.
{% endcomment %}
What you need to do is go through the function that updates the cart
counter and search for the .length attribute - it’s deprecated and likely
what the issue is. Just remove it section by section, compile and keep
going till it works.
Sorry I can’t help anymore but I’m currently not in work and don’t have
access to my code to pinpoint where the issue is.