For some reason my website is displaying the word “El product(s)” instead “0 product(s)”
Here my actual script with jquery:
cartSummary : function(){
if (jQuery('#catCartSummary .cartSummaryItem').html() != 'Shopping cart is empty.') {
var summary = jQuery('#catCartSummary .cartSummaryItem').text().split(" ");
// url = $('#user-options .cart a').attr('href');
jQuery("span.cartTotal").text(summary[0]);
}else{
jQuery("span.cartTotal").text("0 ");
}
}, //cartSummary
checkOutBtn : function(){
var cartTotal = jQuery("span.cartTotal").text();
if(cartTotal > 0){
jQuery("a.view-cart").css('background-position','0 -26px');
}
}, // checkOutBtn
My HTML code:
<strong><span class="cart-info"><span class="cartTotal"></span> product(s) </span></strong> <a class="view-cart" href="/OrderRetrievev2.aspx">View cart</a>
You trying to compare
html()withtext, then splittextand settingcartTotal. Please showcartSummaryItem.