add cart field
parent
3f981767f9
commit
eeb8ad675b
|
@ -54,8 +54,16 @@ $(window).on('load', function(){
|
||||||
updateProducts();
|
updateProducts();
|
||||||
$("#successful-submitting-form").delay(4000).slideUp(200, function() { $(this).alert('close'); });
|
$("#successful-submitting-form").delay(4000).slideUp(200, function() { $(this).alert('close'); });
|
||||||
$('#anfrage').submit(function(){
|
$('#anfrage').submit(function(){
|
||||||
objProducts = [];
|
getInfoFromSelectedProduct().done(function(response, status){
|
||||||
localStorage.setItem("products", JSON.stringify(objProducts));
|
let products = response.contents.map(product => {
|
||||||
|
product = getProductInfo(product);
|
||||||
|
product = calculatePrice(product);
|
||||||
|
return product;
|
||||||
|
});
|
||||||
|
$('#ccart').val(JSON.stringify({"total-price": totalPrice, "products": products}));
|
||||||
|
objProducts = [];
|
||||||
|
localStorage.setItem("products", JSON.stringify(objProducts));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
$(document).on('click', '.btn-remove-product', function(){
|
$(document).on('click', '.btn-remove-product', function(){
|
||||||
if(objProducts.length > 0){
|
if(objProducts.length > 0){
|
||||||
|
|
|
@ -17,7 +17,7 @@ function getQuantityOfProducts(){
|
||||||
|
|
||||||
function getProductInfo(productInfo){
|
function getProductInfo(productInfo){
|
||||||
let objProduct = objProducts.find(obj => obj.id == productInfo.id);
|
let objProduct = objProducts.find(obj => obj.id == productInfo.id);
|
||||||
return jQuery.extend([], objProduct, productInfo);
|
return jQuery.extend({}, objProduct, productInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculatePrice(objProduct){
|
function calculatePrice(objProduct){
|
||||||
|
|
|
@ -109,6 +109,7 @@
|
||||||
<br>
|
<br>
|
||||||
@endif
|
@endif
|
||||||
<x-form id="anfrage" id-name="anfrage" channels="bestaetigung,airtable">
|
<x-form id="anfrage" id-name="anfrage" channels="bestaetigung,airtable">
|
||||||
|
<input type="hidden" name="cart" id="ccart">
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label for="" class="form-label">Anrede</label>
|
<label for="" class="form-label">Anrede</label>
|
||||||
<select class="form-select" name="anrede" aria-label="Default select example">
|
<select class="form-select" name="anrede" aria-label="Default select example">
|
||||||
|
|
Loading…
Reference in New Issue