Gustavo Luigi 2023-10-30 21:24:14 -03:00
parent 9bc52c7bb9
commit ed1308bb5a
1 changed files with 56 additions and 39 deletions

View File

@ -134,16 +134,18 @@ document.addEventListener('DOMContentLoaded', async () => {
}
});

/* document.querySelectorAll('.select-quantity').forEach(async input => {
document.body.addEventListener('click', async function (event) {
if (event.target.matches('.select-quantity')) {

let input = event.target;

let quantity = input.value;
let productId = input.getAttribute('data-id');

Cart.updateItem(productId, { quantity: quantity });
Cart.updateItem(productId, { quantity: input.value });

let product = Cart.getItem(productId);

let elementPrice = `
/* let elementPrice = `
<span>${numberToEuroFormat(product.calc_preis)}</span>`;
if (product.calc_preis != product.preis) elementPrice += `
<br>
@ -153,7 +155,20 @@ document.addEventListener('DOMContentLoaded', async () => {
</button>
<span class="badge text-bg-dark">${(((product.calc_preis - product.preis) * 100) / product.preis).toFixed(2)} %</span>
`;
input.parentElement.parentElement.querySelector('.product-price').innerHTML = elementPrice;
input.parentElement.parentElement.querySelector('.product-price').innerHTML = elementPrice; */

let quantity = await Cart.getQuantity();
document.querySelectorAll('.js-product-counter').forEach(element => {
element.innerText = quantity;

if (quantity > 0) element.style.display = "block";
else element.style.display = "none";
});

let totalPrice = await Cart.getTotalPrice();
document.querySelectorAll(".js-total-price").forEach(element => {
element.innerText = numberToEuroFormat(totalPrice);
});

quantity = await Cart.getQuantity();
document.querySelectorAll('.js-product-counter').forEach(counter => {
@ -162,9 +177,9 @@ document.addEventListener('DOMContentLoaded', async () => {
else counter.style.display = "none";
});

document.querySelector('#total-price').innerText = numberToEuroFormat(Cart.getTotalPrice());
//document.querySelector('#total-price').innerText = numberToEuroFormat(Cart.getTotalPrice());

productId = document.querySelector('meta[name="product-id"]').getAttribute('content');
/* productId = document.querySelector('meta[name="product-id"]').getAttribute('content');
if (productId != undefined) {
let objProduct = objProducts.find(obj => obj.id == productId);
if (objProduct == undefined) {
@ -179,8 +194,10 @@ document.addEventListener('DOMContentLoaded', async () => {
$('#btn-check-out').parent().hide();
$('#count-items-in-bag').html(objProduct.quantity + `<svg style="fill: white; width: 12px; margin-left: 3px; margin-bottom: 2px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M352 128C352 57.42 294.579 0 224 0 153.42 0 96 57.42 96 128H0v304c0 44.183 35.817 80 80 80h288c44.183 0 80-35.817 80-80V128h-96zM224 48c44.112 0 80 35.888 80 80H144c0-44.112 35.888-80 80-80zm176 384c0 17.645-14.355 32-32 32H80c-17.645 0-32-14.355-32-32V176h48v40c0 13.255 10.745 24 24 24s24-10.745 24-24v-40h160v40c0 13.255 10.745 24 24 24s24-10.745 24-24v-40h48v256z"/></svg>`);
}
} */

}
} ); * /
});

/* let sharedCode = getSharedCode();
if (sharedCode) {