Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
How do I find the exact total of the cart(Javascript)

I have made an online food ordering website all is done but I don't know I am getting sum BUG in finding the total The javascript updatecartTotal() method which finds total goes like this

   
    var cartItemContainer = document.getElementsByClassName('cart-items')[0]
    var rowvar = cartItemContainer.getElementsByClassName('cart-row')
    var total = 0
    

    
    for (var i = 0; i < rowvar.length; i++) {
        var rowvar = rowvar[i]
        var priceElement = rowvar.getElementsByClassName('cart-price')[0]
        var quantityElement = rowvar.getElementsByClassName('cart-quantity-input')[0]
        var price = parseFloat(priceElement.innerText.replace('₹', ''))
        var quantity = parseInt(quantityElement.value)
        z = (price * quantity)
        console.log(price)
        console.log(z)
        console.log(quantity)
        total = (Math.round(z*5/100))  + (quantity*total) + (z)
        
        console.log(total)
    }
}

I want a gst of 5 percent NOT ON ULTIMATE FINAL PRICE I want it on final price of each food item then add all final prices to get ULTIMATE FINAL PRICE which is our total.It is quite confusing bug for me hope you can solve it.

Here price is just the price per piece of item

Thank You

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda