DSatishchandra commited on
Commit
2e74128
·
verified ·
1 Parent(s): 4841ad9

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +4 -1
templates/menu.html CHANGED
@@ -695,8 +695,10 @@ function updateCartDisplay(cart) {
695
  console.error('Invalid cart data:', cart);
696
  return;
697
  }
 
698
  const cartCountElement = document.getElementById('cart-count');
699
- cartCountElement.innerText = cart.length; // Update cart item count
 
700
  // Optionally, show a small success notification that the item was added
701
  const successNotification = document.createElement('div');
702
  successNotification.classList.add('success-notification');
@@ -706,6 +708,7 @@ function updateCartDisplay(cart) {
706
  successNotification.remove(); // Remove success notification after a few seconds
707
  }, 2000);
708
  }
 
709
  document.addEventListener('DOMContentLoaded', function () {
710
  // Get references to the quantity buttons and the input field
711
  const decreaseBtn = document.getElementById('decreaseQuantity');
 
695
  console.error('Invalid cart data:', cart);
696
  return;
697
  }
698
+ // Optional: Update quantity on the cart page
699
  const cartCountElement = document.getElementById('cart-count');
700
+ cartCountElement.innerText = cart.reduce((total, item)=> total+item.quantity,0); // Update cart item count //Sum of all quantities
701
+
702
  // Optionally, show a small success notification that the item was added
703
  const successNotification = document.createElement('div');
704
  successNotification.classList.add('success-notification');
 
708
  successNotification.remove(); // Remove success notification after a few seconds
709
  }, 2000);
710
  }
711
+
712
  document.addEventListener('DOMContentLoaded', function () {
713
  // Get references to the quantity buttons and the input field
714
  const decreaseBtn = document.getElementById('decreaseQuantity');