Spaces:
Sleeping
Sleeping
Update templates/menu.html
Browse files- templates/menu.html +52 -52
templates/menu.html
CHANGED
@@ -1043,14 +1043,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
1043 |
});
|
1044 |
}
|
1045 |
// Function to increase quantity
|
1046 |
-
function increaseQuantity(name, index) {
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
|
1052 |
-
|
1053 |
-
}
|
1054 |
|
1055 |
// Function to decrease quantity
|
1056 |
// function decreaseQuantity(name, index) {
|
@@ -1066,55 +1066,55 @@ function increaseQuantity(name, index) {
|
|
1066 |
// }
|
1067 |
// }
|
1068 |
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
}
|
1089 |
// Existing updateCartUI function (unchanged, but included for reference)
|
1090 |
-
function updateCartUI(cart) {
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
}
|
1100 |
|
1101 |
-
// Remove Item from Cart when quantity reaches 0
|
1102 |
-
function removeFromCart(name, index) {
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
}
|
1118 |
|
1119 |
|
1120 |
|
|
|
1043 |
});
|
1044 |
}
|
1045 |
// Function to increase quantity
|
1046 |
+
// function increaseQuantity(name, index) {
|
1047 |
+
// let quantityElement = document.getElementById(`quantity-${index}`);
|
1048 |
+
// let currentQuantity = parseInt(quantityElement.innerText);
|
1049 |
+
// currentQuantity++;
|
1050 |
+
// quantityElement.innerText = currentQuantity;
|
1051 |
|
1052 |
+
// updateQuantity(name, currentQuantity);
|
1053 |
+
// }
|
1054 |
|
1055 |
// Function to decrease quantity
|
1056 |
// function decreaseQuantity(name, index) {
|
|
|
1066 |
// }
|
1067 |
// }
|
1068 |
|
1069 |
+
// function decreaseQuantity(name, index) {
|
1070 |
+
// let quantityElement = document.getElementById(`quantity-${index}`);
|
1071 |
+
// let currentQuantity = parseInt(quantityElement.innerText);
|
1072 |
|
1073 |
+
// // If quantity > 0, decrease the quantity
|
1074 |
+
// if (currentQuantity > 0) {
|
1075 |
+
// currentQuantity--;
|
1076 |
+
// quantityElement.innerText = currentQuantity;
|
1077 |
|
1078 |
+
// // If quantity becomes 0, show "Add" button and hide quantity controls
|
1079 |
+
// if (currentQuantity === 0) {
|
1080 |
+
// document.getElementById(`add-btn-${index}`).style.display = 'block'; // Show "Add" button
|
1081 |
+
// document.getElementById(`quantity-control-${index}`).style.display = 'none'; // Hide quantity controls
|
1082 |
+
// removeFromCart(name, index); // Remove item from the cart when quantity reaches 0
|
1083 |
+
// } else {
|
1084 |
+
// // Otherwise, update cart quantity
|
1085 |
+
// updateQuantity(name, currentQuantity);
|
1086 |
+
// }
|
1087 |
+
// }
|
1088 |
+
// }
|
1089 |
// Existing updateCartUI function (unchanged, but included for reference)
|
1090 |
+
// function updateCartUI(cart) {
|
1091 |
+
// if (!Array.isArray(cart)) {
|
1092 |
+
// console.error('Invalid cart data:', cart);
|
1093 |
+
// return;
|
1094 |
+
// }
|
1095 |
+
// const cartIcon = document.getElementById('cart-icon');
|
1096 |
+
// if (cartIcon) {
|
1097 |
+
// cartIcon.innerText = cart.length; // Update cart icon if it exists
|
1098 |
+
// }
|
1099 |
+
// }
|
1100 |
|
1101 |
+
// // Remove Item from Cart when quantity reaches 0
|
1102 |
+
// function removeFromCart(name, index) {
|
1103 |
+
// fetch('/cart/remove_item', {
|
1104 |
+
// method: 'DELETE',
|
1105 |
+
// headers: { 'Content-Type': 'application/json' },
|
1106 |
+
// body: JSON.stringify({ item_name: name.trim() })
|
1107 |
+
// })
|
1108 |
+
// .then(response => response.json())
|
1109 |
+
// .then(data => {
|
1110 |
+
// if (data.success) {
|
1111 |
+
// updateCartDisplay(data.cart); // Update the cart UI after removal
|
1112 |
+
// } else {
|
1113 |
+
// alert(data.error || "Failed to remove item from cart.");
|
1114 |
+
// }
|
1115 |
+
// })
|
1116 |
+
// .catch(err => console.error("Error removing item from cart:", err));
|
1117 |
+
// }
|
1118 |
|
1119 |
|
1120 |
|