DSatishchandra commited on
Commit
9be918b
·
verified ·
1 Parent(s): 0463947

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. 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
- .then(data => {
557
- if (data.success) {
558
- alert('Item added to cart successfully!');
559
- updateCartUI(data.cart); // Update cart UI after adding an item
560
- const modal = document.getElementById('itemModal');
561
- const modalInstance = bootstrap.Modal.getInstance(modal);
562
- modalInstance.hide();
563
- } else {
564
- alert(data.error || 'Failed to add item to cart.');
565
- }
566
- })
567
- .catch(err => {
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)) {