Spaces:
Sleeping
Sleeping
Update templates/menu.html
Browse files- templates/menu.html +12 -16
templates/menu.html
CHANGED
|
@@ -553,22 +553,18 @@ function addToCartFromModal() {
|
|
| 553 |
body: JSON.stringify(cartPayload)
|
| 554 |
})
|
| 555 |
.then(response => response.json())
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
console.error('Error adding item to cart:', err);
|
| 569 |
-
alert('An error occurred while adding the item to the cart.');
|
| 570 |
-
});
|
| 571 |
-
}
|
| 572 |
|
| 573 |
function updateCartUI(cart) {
|
| 574 |
if (!Array.isArray(cart)) {
|
|
|
|
| 553 |
body: JSON.stringify(cartPayload)
|
| 554 |
})
|
| 555 |
.then(response => response.json())
|
| 556 |
+
.then(data => {
|
| 557 |
+
if (data.success) {
|
| 558 |
+
updateCartUI(data.cart); // Update the cart icon or cart details on the same page
|
| 559 |
+
alert('Item added to cart!');
|
| 560 |
+
} else {
|
| 561 |
+
alert(data.error || 'Failed to add item to cart.');
|
| 562 |
+
}
|
| 563 |
+
})
|
| 564 |
+
.catch(err => {
|
| 565 |
+
console.error('Error adding item to cart:', err);
|
| 566 |
+
alert('An error occurred while adding the item to the cart.');
|
| 567 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 568 |
|
| 569 |
function updateCartUI(cart) {
|
| 570 |
if (!Array.isArray(cart)) {
|