diff --git a/assets/js/checkout.js b/assets/js/checkout.js index 249c57d..d27f6e5 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -12,8 +12,9 @@ function getAddressFiedlValue(addressComponents, $field){ } let input = document.querySelector("#ctelefon"); +let iti = null; if(input != undefined){ - let iti = window.intlTelInput(input, { + iti = window.intlTelInput(input, { initialCountry: "de", preferredCountries: ["de"], geoIpLookup: function(callback) { @@ -34,22 +35,37 @@ 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(); + $('#total-checkout-price').parent().parent().parent().hide(); + $('#no-products-in-checkout').hide(); + $('#cart-error-in-checkout').show(); }); $('#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{ + $('#cart-error-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(); + $('#cart-error-in-checkout').hide(); } } -// iti.getNumber(); - $(window).on('load', function(){ updateProducts(); $("#successful-submitting-form").delay(4000).slideUp(200, function() { $(this).alert('close'); }); @@ -60,9 +76,11 @@ $(window).on('load', function(){ let products = response.contents.map(product => { product = getProductInfo(product); product = calculatePrice(product); - return product; + return product.quantity+'x '+product.title+' ('+numberToEuroFormat(product.calc_preis)+')'; }); - $('#ccart').val(JSON.stringify({"total-price": totalPrice, "products": products})); + let cart = products.join(" - ")+" - Gesammt: "+numberToEuroFormat(totalPrice); + $('#ccart').val(cart); + $('#ctelefon').val(iti.getNumber()); objProducts = []; localStorage.setItem("products", JSON.stringify(objProducts)); form.unbind('submit').submit(); diff --git a/assets/js/methods.js b/assets/js/methods.js index 30b495d..0a7450d 100644 --- a/assets/js/methods.js +++ b/assets/js/methods.js @@ -113,6 +113,15 @@ function updateProductsInLocalStorage(){ $('#list-products-in-bag').append(elementProduct); }); $('#total-price').text(numberToEuroFormat(totalPrice)); + }).fail(function(response){ + $('.cart-link').hide(); + $(".btn-share").hide(); + $('#count-products-in-bag').hide(); + $('#list-products-in-bag').parent().parent().parent().parent().parent().find('.modal-footer').hide(); + $('#total-price').parent().parent().parent().hide(); + $('#no-products').hide(); + $('#cart-error').show(); + $('#modal-buttons').hide(); }); $('.cart-link').show(); $(".btn-share").show(); @@ -120,6 +129,7 @@ function updateProductsInLocalStorage(){ $('#list-products-in-bag').parent().parent().parent().parent().parent().find('.modal-footer').show(); $('#total-price').parent().parent().parent().show(); $('#no-products').hide(); + $('#cart-error').hide(); $('#modal-buttons').show(); cartLink = window.location.origin+'/'+btoa(JSON.stringify(objProducts)); @@ -139,6 +149,7 @@ function updateProductsInLocalStorage(){ $('#list-products-in-bag').parent().parent().parent().parent().parent().find('.modal-footer').hide(); $('#total-price').parent().parent().parent().hide(); $('#no-products').show(); + $('#cart-error').hide(); $('#modal-buttons').hide(); } let productId = $('meta[name="product-id"]').attr('content'); diff --git a/content-types.json b/content-types.json index 4ef5587..24da23c 100644 --- a/content-types.json +++ b/content-types.json @@ -1 +1 @@ -{"content-types":[{"slug":"solarmodule","name":"Solarmodule","description":"Solarmodule","icon":"solar-panel","status":1,"blade":"solarmodule","fields":[{"name":"Beschreibung","type":"textfield","description":"","position":1,"required":0,"default_value":""},{"name":"Hersteller","type":"select","description":"","position":2,"required":1,"default_value":"","options":["JA Solar","Longi"]},{"name":"Preis","type":"number","description":"","attr":{"min":"0","step":"0.01"},"position":5,"required":1,"default_value":""},{"name":"Lieferumfang","type":"textfield","description":"","position":3,"required":1,"default_value":""},{"name":"preis_5","type":"number","description":"Preis pro Modul bei Abnahme ab 5 St\u00fcck","attr":{"max":"500","min":"0","step":"0.01"},"position":4,"required":0,"default_value":""},{"name":"preis_10","type":"number","description":"Preis pro Modul bei Abnahme ab 10 St\u00fcck","attr":{"min":"0","step":"0.01"},"position":6,"required":0,"default_value":""},{"name":"preis_palette","type":"number","description":"Preis pro Modul bei Abnahme von einer geschlossenen Palette","attr":{"min":"0","step":"0.01"},"position":7,"required":0,"default_value":""},{"name":"Module pro Palette","type":"number","description":"","attr":{"max":"50","min":"0","step":"1"},"position":8,"required":1,"default_value":""},{"name":"Leistung","type":"number","description":"Leistung in Wp des Moduls","attr":{"min":"0","step":"1"},"position":9,"required":1,"default_value":""}]},{"slug":"balkonkraftwerk","name":"Balkonkraftwerk","description":"Produkt","icon":"shopping-bag","status":1,"blade":"balkonkraftwerk","fields":[{"name":"Preis","type":"number","description":"","position":1,"required":1,"default_value":""},{"name":"Beschreibung","type":"textfield","description":"","position":2,"required":1,"default_value":""},{"name":"Kurzbeschreibung","type":"textfield","description":"","position":3,"required":1,"default_value":""},{"name":"Technische Daten","type":"textfield","description":"","position":4,"required":0,"default_value":""}]},{"slug":"kabel","name":"Kabel","description":"Solar und AC Kabel","icon":"parking","status":1,"blade":"balkonkraftwerk","fields":[{"name":"L\u00e4nge","type":"number","description":"","attr":{"min":"0","step":"1"},"position":1,"required":0,"default_value":""},{"name":"Preis","type":"number","description":"","attr":{"min":"0","step":"0.01"},"position":2,"required":1,"default_value":""}]},{"slug":"befestigung","name":"Befestigung","description":"d","icon":"hammer","status":1,"blade":"balkonkraftwerk","fields":[{"name":"preis","type":"number","description":"","attr":{"min":"0","step":"0.01"},"position":1,"required":1,"default_value":""}]}]} +[{"slug":"solarmodule","name":"Solarmodule","description":"Solarmodule","icon":"solar-panel","status":1,"blade":"solarmodule","fields":[{"name":"Beschreibung","type":"textfield","description":"","position":1,"required":0,"default_value":""},{"name":"Hersteller","type":"select","description":"","position":2,"required":1,"default_value":"","options":["JA Solar","Longi"]},{"name":"Preis","type":"number","description":"","attr":{"min":"0","step":"0.01"},"position":5,"required":1,"default_value":""},{"name":"Lieferumfang","type":"textfield","description":"","position":3,"required":1,"default_value":""},{"name":"preis_5","type":"number","description":"Preis pro Modul bei Abnahme ab 5 St\u00fcck","attr":{"max":"500","min":"0","step":"0.01"},"position":4,"required":0,"default_value":""},{"name":"preis_10","type":"number","description":"Preis pro Modul bei Abnahme ab 10 St\u00fcck","attr":{"min":"0","step":"0.01"},"position":6,"required":0,"default_value":""},{"name":"preis_palette","type":"number","description":"Preis pro Modul bei Abnahme von einer geschlossenen Palette","attr":{"min":"0","step":"0.01"},"position":7,"required":0,"default_value":""},{"name":"Module pro Palette","type":"number","description":"","attr":{"max":"50","min":"0","step":"1"},"position":8,"required":1,"default_value":""},{"name":"Leistung","type":"number","description":"Leistung in Wp des Moduls","attr":{"min":"0","step":"1"},"position":9,"required":1,"default_value":""}]},{"slug":"balkonkraftwerk","name":"Balkonkraftwerk","description":"Produkt","icon":"shopping-bag","status":1,"blade":"balkonkraftwerk","fields":[{"name":"Preis","type":"number","description":"","position":1,"required":1,"default_value":""},{"name":"Beschreibung","type":"textfield","description":"","position":2,"required":1,"default_value":""},{"name":"Kurzbeschreibung","type":"textfield","description":"","position":3,"required":1,"default_value":""},{"name":"Technische Daten","type":"textfield","description":"","position":4,"required":0,"default_value":""}]},{"slug":"kabel","name":"Kabel","description":"Solar und AC Kabel","icon":"parking","status":1,"blade":"balkonkraftwerk","fields":[{"name":"L\u00e4nge","type":"number","description":"","attr":{"min":"0","step":"1"},"position":1,"required":0,"default_value":""},{"name":"Preis","type":"number","description":"","attr":{"min":"0","step":"0.01"},"position":2,"required":1,"default_value":""}]},{"slug":"befestigung","name":"Befestigung","description":"d","icon":"hammer","status":1,"blade":"balkonkraftwerk","fields":[{"name":"preis","type":"number","description":"","attr":{"min":"0","step":"0.01"},"position":1,"required":1,"default_value":""}]}] \ No newline at end of file diff --git a/content/master.blade.php b/content/master.blade.php index f454446..22d451d 100644 --- a/content/master.blade.php +++ b/content/master.blade.php @@ -112,6 +112,9 @@