Spaces:
Runtime error
Runtime error
Update templates/menu.html
Browse files- templates/menu.html +7 -4
templates/menu.html
CHANGED
@@ -1855,14 +1855,17 @@
|
|
1855 |
return;
|
1856 |
}
|
1857 |
|
1858 |
-
// Calculate total items in cart
|
1859 |
-
|
|
|
|
|
|
|
1860 |
|
1861 |
// Update cart icon badge
|
1862 |
const cartIcon = document.getElementById('cart-icon');
|
1863 |
if (cartIcon) {
|
1864 |
-
cartIcon.innerText =
|
1865 |
-
cartIcon.style.display =
|
1866 |
}
|
1867 |
|
1868 |
const buttonContainers = document.querySelectorAll('.button-container');
|
|
|
1855 |
return;
|
1856 |
}
|
1857 |
|
1858 |
+
// Calculate total quantity of items in cart
|
1859 |
+
let totalQuantity = 0;
|
1860 |
+
cart.forEach(item => {
|
1861 |
+
totalQuantity += item.quantity;
|
1862 |
+
});
|
1863 |
|
1864 |
// Update cart icon badge
|
1865 |
const cartIcon = document.getElementById('cart-icon');
|
1866 |
if (cartIcon) {
|
1867 |
+
cartIcon.innerText = totalQuantity;
|
1868 |
+
cartIcon.style.display = totalQuantity > 0 ? 'flex' : 'none';
|
1869 |
}
|
1870 |
|
1871 |
const buttonContainers = document.querySelectorAll('.button-container');
|