Subbu1304 commited on
Commit
364a449
·
verified ·
1 Parent(s): 473a621

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +44 -44
templates/menu.html CHANGED
@@ -963,7 +963,46 @@ document.addEventListener('DOMContentLoaded', function () {
963
  });
964
 
965
  // Function to add Soft Drink to cart directly
966
- // function addSoftDrinkToCart(name, price, image, section, category, index) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
967
  // const itemPrice = parseFloat(price);
968
  // const quantity = 1; // Default quantity
969
 
@@ -978,6 +1017,7 @@ document.addEventListener('DOMContentLoaded', function () {
978
  // quantity: quantity
979
  // };
980
 
 
981
  // fetch('/cart/add', {
982
  // method: 'POST',
983
  // headers: {
@@ -988,11 +1028,11 @@ document.addEventListener('DOMContentLoaded', function () {
988
  // .then(response => response.json())
989
  // .then(data => {
990
  // if (data.success) {
991
- // // Hide the ADD button and show quantity controls
992
  // document.getElementById(`add-btn-${index}`).style.display = 'none';
993
  // document.getElementById(`quantity-control-${index}`).style.display = 'flex';
994
- // updateCartUI(data.cart);
995
- // alert('Soft Drink added to cart successfully!');
996
  // } else {
997
  // alert(data.error || 'Failed to add Soft Drink to cart.');
998
  // }
@@ -1002,46 +1042,6 @@ document.addEventListener('DOMContentLoaded', function () {
1002
  // alert('An error occurred while adding the Soft Drink to the cart.');
1003
  // });
1004
  // }
1005
- function addSoftDrinkToCart(name, price, image, section, category, index) {
1006
- const itemPrice = parseFloat(price);
1007
- const quantity = 1; // Default quantity
1008
-
1009
- const cartPayload = {
1010
- itemName: name,
1011
- itemPrice: itemPrice,
1012
- itemImage: image || '/static/placeholder.jpg',
1013
- section: section,
1014
- category: category,
1015
- addons: [], // No add-ons for Soft Drinks
1016
- instructions: '', // No instructions for Soft Drinks
1017
- quantity: quantity
1018
- };
1019
-
1020
- // Add item to cart
1021
- fetch('/cart/add', {
1022
- method: 'POST',
1023
- headers: {
1024
- 'Content-Type': 'application/json',
1025
- },
1026
- body: JSON.stringify(cartPayload)
1027
- })
1028
- .then(response => response.json())
1029
- .then(data => {
1030
- if (data.success) {
1031
- // Hide the "Add" button and show quantity controls
1032
- document.getElementById(`add-btn-${index}`).style.display = 'none';
1033
- document.getElementById(`quantity-control-${index}`).style.display = 'flex';
1034
- updateCartQuantity(data.cart);
1035
- alert('Soft Drink added to cart successfully!');
1036
- } else {
1037
- alert(data.error || 'Failed to add Soft Drink to cart.');
1038
- }
1039
- })
1040
- .catch(err => {
1041
- console.error('Error adding Soft Drink to cart:', err);
1042
- alert('An error occurred while adding the Soft Drink to the cart.');
1043
- });
1044
- }
1045
  // Function to increase quantity
1046
  // function increaseQuantity(name, index) {
1047
  // let quantityElement = document.getElementById(`quantity-${index}`);
 
963
  });
964
 
965
  // Function to add Soft Drink to cart directly
966
+ function addSoftDrinkToCart(name, price, image, section, category, index) {
967
+ // // const itemPrice = parseFloat(price);
968
+ // // const quantity = 1; // Default quantity
969
+
970
+ // // const cartPayload = {
971
+ // // itemName: name,
972
+ // // itemPrice: itemPrice,
973
+ // // itemImage: image || '/static/placeholder.jpg',
974
+ // // section: section,
975
+ // // category: category,
976
+ // // addons: [], // No add-ons for Soft Drinks
977
+ // // instructions: '', // No instructions for Soft Drinks
978
+ // quantity: quantity
979
+ // };
980
+
981
+ // fetch('/cart/add', {
982
+ // method: 'POST',
983
+ // headers: {
984
+ // 'Content-Type': 'application/json',
985
+ // },
986
+ // body: JSON.stringify(cartPayload)
987
+ // })
988
+ // .then(response => response.json())
989
+ // .then(data => {
990
+ // if (data.success) {
991
+ // // Hide the ADD button and show quantity controls
992
+ // document.getElementById(`add-btn-${index}`).style.display = 'none';
993
+ // document.getElementById(`quantity-control-${index}`).style.display = 'flex';
994
+ // updateCartUI(data.cart);
995
+ // alert('Soft Drink added to cart successfully!');
996
+ // } else {
997
+ // alert(data.error || 'Failed to add Soft Drink to cart.');
998
+ // }
999
+ // })
1000
+ // .catch(err => {
1001
+ // console.error('Error adding Soft Drink to cart:', err);
1002
+ // alert('An error occurred while adding the Soft Drink to the cart.');
1003
+ // });
1004
+ }
1005
+ // function addSoftDrinkToCart(name, price, image, section, category, index) {
1006
  // const itemPrice = parseFloat(price);
1007
  // const quantity = 1; // Default quantity
1008
 
 
1017
  // quantity: quantity
1018
  // };
1019
 
1020
+ // // Add item to cart
1021
  // fetch('/cart/add', {
1022
  // method: 'POST',
1023
  // headers: {
 
1028
  // .then(response => response.json())
1029
  // .then(data => {
1030
  // if (data.success) {
1031
+ // // Hide the "Add" button and show quantity controls
1032
  // document.getElementById(`add-btn-${index}`).style.display = 'none';
1033
  // document.getElementById(`quantity-control-${index}`).style.display = 'flex';
1034
+ // updateCartQuantity(data.cart);
1035
+ // alert('{item.name} added to cart successfully!');
1036
  // } else {
1037
  // alert(data.error || 'Failed to add Soft Drink to cart.');
1038
  // }
 
1042
  // alert('An error occurred while adding the Soft Drink to the cart.');
1043
  // });
1044
  // }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1045
  // Function to increase quantity
1046
  // function increaseQuantity(name, index) {
1047
  // let quantityElement = document.getElementById(`quantity-${index}`);