Cart Counter not working

ProperIconic
New Member
10 0 0

Hi, 

 

Does anyone know why when adding products to basket my cart counter doesn't update in the top corner? The product is in the cart but it still displays as (0) until you refresh or proceed to checkout. 

This is the coding from theme.js if this helps...

 

enableAjax: function() {
this.selectors.$addToCartBtn.on('click', function(evt) {
evt.preventDefault();
$('.errors').remove();
var $addToCartBtn = $(this),
$addToCartForm = $(this).closest('form'),
$addToCartText = $(this).find('span');
if ($addToCartForm.length) {
$addToCartBtn
.data('add-to-cart', $addToCartText.text())
.prop('disabled', true)
.addClass('btn--ajax-disabled');
$.ajax({
url: '/cart/add.js',
dataType: 'json',
type: 'post',
data: $addToCartForm.serialize(),
success: function() {
// reupdate cart count
theme.afterCartLoad();
$addToCartBtn.prop('disabled', false);
$addToCartBtn.removeClass('btn--ajax-disabled');
addToCartflip($addToCartBtn);
},
error: function(XMLHttpRequest) {
var data = eval('(' + XMLHttpRequest.responseText + ')');
var response = data.description;
var status = XMLHttpRequest.status;
$addToCartBtn.removeClass('btn--ajax-disabled');
if (status === 422) {
$addToCartText.text(theme.strings.soldOut);
} else {
$addToCartBtn.prop('disabled', false);
$addToCartText.text($addToCartBtn.data('add-to-cart'));
}
$addToCartBtn.after('<p class="errors">' + response + '</p>');

0 Likes