Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda