master
parent
307d50219c
commit
65543e6617
|
@ -129,6 +129,7 @@
|
||||||
for(let i = 0; i < quantitys.length; i++) { quantityOfProducts += Number(quantitys[i]); }
|
for(let i = 0; i < quantitys.length; i++) { quantityOfProducts += Number(quantitys[i]); }
|
||||||
$('#count-products-in-bag').text(quantityOfProducts);
|
$('#count-products-in-bag').text(quantityOfProducts);
|
||||||
$('#list-products-in-bag').html('');
|
$('#list-products-in-bag').html('');
|
||||||
|
if(typeof updateProducts === "function") $('#list-products').html('');
|
||||||
totalPrice = 0;
|
totalPrice = 0;
|
||||||
if(objProducts.length > 0) {
|
if(objProducts.length > 0) {
|
||||||
let ids = objProducts.map(obj => obj.id);
|
let ids = objProducts.map(obj => obj.id);
|
||||||
|
@ -158,18 +159,32 @@
|
||||||
<td class="align-middle text-end">${formatter.format(item.data_fields.preis)}</td>
|
<td class="align-middle text-end">${formatter.format(item.data_fields.preis)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
$('#list-products-in-bag').append(elementProduct);
|
$('#list-products-in-bag').append(elementProduct);
|
||||||
|
if(typeof updateProducts === "function") $('#list-products').append(elementProduct);
|
||||||
});
|
});
|
||||||
$('#total-price').text(formatter.format(totalPrice));
|
$('#total-price').text(formatter.format(totalPrice));
|
||||||
|
if(typeof updateProducts === "function") $('#total-checkout-price').text(formatter.format(totalPrice));
|
||||||
});
|
});
|
||||||
$('#count-products-in-bag').show();
|
$('#count-products-in-bag').show();
|
||||||
$('#list-products-in-bag').parent().parent().parent().parent().parent().find('.modal-footer').show();
|
$('#list-products-in-bag').parent().parent().parent().parent().parent().find('.modal-footer').show();
|
||||||
$('#total-price').parent().parent().parent().show();
|
$('#total-price').parent().parent().parent().show();
|
||||||
$('#no-products').hide();
|
$('#no-products').hide();
|
||||||
|
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();
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
$('#count-products-in-bag').hide();
|
$('#count-products-in-bag').hide();
|
||||||
$('#list-products-in-bag').parent().parent().parent().parent().parent().find('.modal-footer').hide();
|
$('#list-products-in-bag').parent().parent().parent().parent().parent().find('.modal-footer').hide();
|
||||||
$('#total-price').parent().parent().parent().hide();
|
$('#total-price').parent().parent().parent().hide();
|
||||||
$('#no-products').show();
|
$('#no-products').show();
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$('#total-price').text(formatter.format(totalPrice));
|
$('#total-price').text(formatter.format(totalPrice));
|
||||||
let productId = $('meta[name="product-id"]').attr('content');
|
let productId = $('meta[name="product-id"]').attr('content');
|
||||||
|
|
|
@ -300,58 +300,13 @@
|
||||||
utilsScript: "{{storage('assets/libs/intl-tel-input/js/utils.min.js')}}",
|
utilsScript: "{{storage('assets/libs/intl-tel-input/js/utils.min.js')}}",
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateProducts(){
|
function updateProducts(){}
|
||||||
$('#list-products').html('');
|
|
||||||
if(objProducts.length > 0) {
|
|
||||||
let ids = objProducts.map(obj => obj.id);
|
|
||||||
$.get($('meta[name="get-contents"]').attr('content')+"/"+ids.join(","), function(response, status){
|
|
||||||
response.contents.forEach(function(item){
|
|
||||||
let objProductInfo = objProducts.find(obj => obj.id == item.id);
|
|
||||||
let elementProduct = `
|
|
||||||
<tr>
|
|
||||||
<td class="text-start">
|
|
||||||
<img class="rounded img-fluid" src="https://picsum.photos/120/120">
|
|
||||||
</td>
|
|
||||||
<td class="text-start">
|
|
||||||
<span class="fs-5">${item.title}</span>
|
|
||||||
<br>
|
|
||||||
<small class="text-success">sofort verfügbar</small>
|
|
||||||
<br>
|
|
||||||
<select class="form-select form-select-sm select-quantity" data-id="${item.id}" style="width:125px;" aria-label="Default select example">`;
|
|
||||||
for(let i = 1; i <= 5; i++){
|
|
||||||
if(objProductInfo.quantity == i) elementProduct += `<option selected value="${i}">Anzahl: ${i}</option>`;
|
|
||||||
else elementProduct += `<option value="${i}">Anzahl: ${i}</option>`;
|
|
||||||
}
|
|
||||||
elementProduct += `
|
|
||||||
</select>
|
|
||||||
<button data-id="${item.id}" class="btn-remove-product text-muted small text-decoration-none" style="padding: 0; border: none; background: transparen;">Löschen</button>
|
|
||||||
</td>
|
|
||||||
<td class="align-middle text-end">${formatter.format(item.data_fields.preis)}</td>
|
|
||||||
</tr>`;
|
|
||||||
$('#list-products').append(elementProduct);
|
|
||||||
});
|
|
||||||
$('#total-checkout-price').text(formatter.format(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(){
|
$(window).on('load', function(){
|
||||||
updateProducts();
|
|
||||||
$('#anfrage').submit(function(){
|
$('#anfrage').submit(function(){
|
||||||
objProducts = [];
|
objProducts = [];
|
||||||
updateProductsInLocalStorage();
|
updateProductsInLocalStorage();
|
||||||
});
|
});
|
||||||
$(document).on('click', '.btn-remove-product', function(){ updateProducts(); });
|
|
||||||
$(document).on('change', '.select-quantity', function(){ updateProducts(); });
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@stop
|
@stop
|
||||||
|
|
Loading…
Reference in New Issue