From 8dac256ecf5b4223ce18c7c7a2a8868593a59bd4 Mon Sep 17 00:00:00 2001 From: Gustavo Luigi <=> Date: Wed, 7 Sep 2022 12:46:44 +0200 Subject: [PATCH] remove header in checkout page --- assets/js/checkout.js | 35 +++++++++++++++++++++++++++++++++-- assets/js/methods.js | 17 ++--------------- assets/js/script.js | 1 - content/master.blade.php | 8 +++----- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/assets/js/checkout.js b/assets/js/checkout.js index c6cd70f..6baa1e5 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -72,13 +72,44 @@ if(input != undefined){ utilsScript: "/template/assets/libs/intl-tel-input/js/utils.min.js", }); } - // iti.getNumber(); -function updateProducts(){} +function updateProducts(){ + if(objProducts.length > 0){ + getInfoFromSelectedProduct().done(function(response, status){ + response.contents.forEach(function(product){ + let objProduct = getProductInfo(product); + let elementProduct = createProductElement(objProduct); + $('#list-products').append(elementProduct); + }); + $('#total-checkout-price').text(numberToEuroFormat(totalPrice)); + }); + $('#form-section').show(); + $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').show(); + $('#total-checkout-price').parent().parent().parent().show(); + $('#no-products-in-checkout').hide(); + }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').show(); + } +} $(window).on('load', function(){ + updateProducts(); $("#successful-submitting-form").delay(4000).slideUp(200, function() { $(this).alert('close'); }); $('#anfrage').submit(function(){ objProducts = []; localStorage.setItem("products", JSON.stringify(objProducts)); }); + $(document).on('input', '.select-quantity', function(){ + getInfoFromSelectedProduct().done(function(response, status){ + totalPrice = 0; + response.contents.forEach(function(product){ + let objProduct = getProductInfo(product); + calculatePrice(objProduct); + totalPrice += objProduct.calc_preis*objProduct.quantity; + }); + $('#total-checkout-price').text(numberToEuroFormat(totalPrice)); + }); + }); }); \ No newline at end of file diff --git a/assets/js/methods.js b/assets/js/methods.js index 29e7c59..0172ef7 100644 --- a/assets/js/methods.js +++ b/assets/js/methods.js @@ -100,13 +100,12 @@ function updateProductsInLocalStorage(){ getInfoFromSelectedProduct().done(function(response, status){ response.contents.forEach(function(product){ let objProduct = getProductInfo(product); - totalPrice += objProduct.preis*objProduct.quantity; + objProduct = calculatePrice(objProduct); + totalPrice += objProduct.calc_preis*objProduct.quantity; let elementProduct = createProductElement(objProduct); $('#list-products-in-bag').append(elementProduct); - if(typeof updateProducts === "function") $('#list-products').append(elementProduct); }); $('#total-price').text(numberToEuroFormat(totalPrice)); - if(typeof updateProducts === "function") $('#total-checkout-price').text(numberToEuroFormat(totalPrice)); }); $('.cart-link').show(); $(".btn-share").show(); @@ -115,12 +114,6 @@ function updateProductsInLocalStorage(){ $('#total-price').parent().parent().parent().show(); $('#no-products').hide(); $('#modal-buttons').show(); - if(typeof updateProducts === "function"){ - $('#form-section').show(); - $('#list-products').parent().parent().parent().parent().parent().find('.modal-footer').show(); - $('#total-checkout-price').parent().parent().parent().show(); - $('#no-products-in-checkout').hide(); - } if(window.location.origin == 'http://localhost') cartLink = window.location.origin+'/areya-energy/public/'+btoa(JSON.stringify(objProducts)); else cartLink = window.location.origin+'/'+btoa(JSON.stringify(objProducts)); @@ -139,12 +132,6 @@ function updateProductsInLocalStorage(){ $('#total-price').parent().parent().parent().hide(); $('#no-products').show(); $('#modal-buttons').hide(); - if(typeof updateProducts === "function"){ - $('#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').show(); - } } let productId = $('meta[name="product-id"]').attr('content'); if(productId != undefined){ diff --git a/assets/js/script.js b/assets/js/script.js index c5b761a..5bf3d8a 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -107,7 +107,6 @@ $(window).on('load', function(){ totalPrice += objProduct.calc_preis*objProduct.quantity; }); $('#total-price').text(numberToEuroFormat(totalPrice)); - if(typeof updateProducts === "function") $('#total-checkout-price').text(numberToEuroFormat(totalPrice)); }); productId = $('meta[name="product-id"]').attr('content'); if(productId != undefined){ diff --git a/content/master.blade.php b/content/master.blade.php index edc3f4e..173481c 100644 --- a/content/master.blade.php +++ b/content/master.blade.php @@ -31,9 +31,10 @@
- - -
-