From 1ad1ed317466166882c7d4d242cad7f0bb75a2ab Mon Sep 17 00:00:00 2001 From: Gustavo Luigi <=> Date: Thu, 8 Sep 2022 13:14:40 +0200 Subject: [PATCH] bugfix in send form --- assets/js/checkout.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/assets/js/checkout.js b/assets/js/checkout.js index 8df88eb..f04ab7f 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -34,7 +34,15 @@ function updateProducts(){ let elementProduct = createProductElement(objProduct); $('#list-products').append(elementProduct); }); - $('#total-checkout-price').text(numberToEuroFormat(totalPrice)); + if(totalPrice > 0){ + $('#total-checkout-price').text(numberToEuroFormat(totalPrice)); + }else{ + $('#form-section').hide(); + $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').hide(); + $('#total-checkout-price').parent().parent().parent().hide(); + $('#no-products-in-checkout').hide(); + $('#cart-error-in-checkout').show(); + } }).fail(function(response){ $('#form-section').hide(); $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').hide(); @@ -48,13 +56,6 @@ function updateProducts(){ $('#no-products-in-checkout').hide(); $('#cart-error-in-checkout').hide(); } - else if(totalPrice > 0){ - $('#form-section').hide(); - $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').hide(); - $('#total-checkout-price').parent().parent().parent().hide(); - $('#no-products-in-checkout').hide(); - $('#cart-error-in-checkout').show(); - } else{ $('#form-section').hide(); $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').hide(); @@ -78,7 +79,7 @@ $(window).on('load', function(){ product = calculatePrice(product); return product.quantity+'x '+product.title+' ('+numberToEuroFormat(product.calc_preis)+')'; }); - let cart = products.join("\n")+"\nGesammt: "+numberToEuroFormat(totalPrice); + let cart = products.join(" - ")+" - Gesammt: "+numberToEuroFormat(totalPrice); $('#ccart').val(cart); objProducts = []; localStorage.setItem("products", JSON.stringify(objProducts));