add cart field
parent
3f981767f9
commit
eeb8ad675b
|
@ -54,8 +54,16 @@ $(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));
|
||||
getInfoFromSelectedProduct().done(function(response, status){
|
||||
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(){
|
||||
if(objProducts.length > 0){
|
||||
|
|
|
@ -17,7 +17,7 @@ function getQuantityOfProducts(){
|
|||
|
||||
function getProductInfo(productInfo){
|
||||
let objProduct = objProducts.find(obj => obj.id == productInfo.id);
|
||||
return jQuery.extend([], objProduct, productInfo);
|
||||
return jQuery.extend({}, objProduct, productInfo);
|
||||
}
|
||||
|
||||
function calculatePrice(objProduct){
|
||||
|
|
|
@ -109,6 +109,7 @@
|
|||
<br>
|
||||
@endif
|
||||
<x-form id="anfrage" id-name="anfrage" channels="bestaetigung,airtable">
|
||||
<input type="hidden" name="cart" id="ccart">
|
||||
<div class="mb-4">
|
||||
<label for="" class="form-label">Anrede</label>
|
||||
<select class="form-select" name="anrede" aria-label="Default select example">
|
||||
|
|
Loading…
Reference in New Issue