diff --git a/content/master.blade.php b/content/master.blade.php
index f11a2f3..3eb8f3a 100644
--- a/content/master.blade.php
+++ b/content/master.blade.php
@@ -105,12 +105,15 @@
function updateProductsInLocalStorage(){
localStorage.setItem("products", JSON.stringify(objProducts));
$('#count-products-in-bag').text(objProducts.length);
+ $('#list-products-in-bag').html('');
if(objProducts.length > 0) {
$('#count-products-in-bag').show();
- $.get($('meta[name="get-contents"]').attr('content')+"/"+objProducts.join(","), function(response, status){
- $('#list-products-in-bag').html('');
+ let ids = objProducts.map(obj => obj.id);
+ $.get($('meta[name="get-contents"]').attr('content')+"/"+ids.join(","), function(response, status){
response.contents.forEach(function(item){
- $('#list-products-in-bag').append(`
+ let objProductInfo = objProducts.find(obj => obj.id == item.id);
+
+ let elementProduct = `
@@ -120,26 +123,40 @@
sofort verfügbar
-
- Löschen
+
+
|
18,00€ |
-
`);
+ `;
+
+ $('#list-products-in-bag').append(elementProduct);
});
});
}else $('#count-products-in-bag').hide();
}
function addToBag(productId){
- if(objProducts.indexOf(productId) == -1) objProducts.push(productId+':'+1);
+ if(objProducts.indexOf(productId) == -1) objProducts.push({id: productId, quantity: 1});
updateProductsInLocalStorage();
}
$(window).on('load', function(){
if(localStorage.getItem("products") != null) objProducts = JSON.parse(localStorage.getItem("products"));
updateProductsInLocalStorage();
+ $(document).on('click', '.btn-remove-product', function(){
+ let objProductInfo = objProducts.find(obj => obj.id == $(this).attr('data-id'));
+ let productId = $(this).attr('data-id');
+ let index = objProducts.indexOf(objProductInfo);
+ if(index != -1) objProducts.splice(index, 1);
+ updateProductsInLocalStorage();
+ });
+ $(document).on('change', '.select-quantity', function(){
+
+ });
});
@yield('scripts')