Javascript does not work in mobile but in desktop

0

Good afternoon, valuable community. I have a problem in JS in two functions. It should be noted that it works normally in browser desktop , but in mobile it does not work. Problem: when I add ONE product to the cart in mobile view , the cart counter increases by +10, the total price also. The functions are the following:

function carttotalamount() {
svar productsArray = [];
var sum = 0;
var totalItems = 0;
var totalQuantity = 0;
var test1 = 1;
$("#cspositionstatic  .productrow").each(function( i ) {
    $(this).addClass("pktestdemo"+test1);

    productsArray.push($(this).attr("product"));

    var price = $(this).find(".cspricecrt").val();
    var WithoutCPrice = price.replace("$", "");
    WithoutCPrice = parseFloat(WithoutCPrice.replace(",", "."));

    var qty = $(this).attr("quantity");
    var productPrice = parseFloat(qty * WithoutCPrice);
    sum += Number(productPrice);
    totalQuantity += parseInt(qty);
    totalItems++;
    test1++;
});

$(".cart-products-count").html(totalItems);

sum = parseFloat(sum);
if(sum <= 0) {
    $(".continue-btn").addClass("disable");
} else {    
    $(".continue-btn").removeClass("disable");
}   

var totalprice = String(sum.toFixed(2));
$(".amount.pull-right").html("$ "+totalprice.replace(".", ","));
$("#previewcarttotal").html("$ "+totalprice.replace(".", ","));

if(document.getElementById("previewcarttotal")){
    if(sum >= 90){
        document.getElementById("myCartBar").style.width = "90%";
        document.getElementById("freeshipmsg").innerText = "¡Felicitaciones! El envio de tu compra es GRATIS";
        document.getElementById("freeship-icon-pump").style.display = "block";          
    }else{
        document.getElementById("myCartBar").style.width = (sum * 90)/90 + '%';
        document.getElementById("freeshipmsg").innerText = "Superando los $90, tu envio es GRATIS";
        document.getElementById("freeship-icon-pump").style.display = "none";
    }
}

if(sum <= 0){
    $('.cart-products-count').html('0');
    $('.cs-no-item-message').show();
    $('.cart-footer').show();
    $('#freeshipmsg').hide();
    $('#myCartProgress').hide();
    $('#previewcarttotal').html('0');
}else{
    $('.cart-products-count').html(totalQuantity);
    $('.cs-no-item-message').hide();
    $('.cart-footer').show();
    $('#freeshipmsg').show();
    $('#myCartProgress').show();
 }
}
    
asked by Andres Matias 10.09.2018 в 19:04
source

0 answers