Spaces:
Sleeping
Sleeping
Update templates/menu_page.html
Browse files- templates/menu_page.html +0 -38
templates/menu_page.html
CHANGED
@@ -171,44 +171,6 @@
|
|
171 |
});
|
172 |
}
|
173 |
|
174 |
-
// ✅ Cart Functionality
|
175 |
-
let cart = [];
|
176 |
-
|
177 |
-
function addToCart(name, price) {
|
178 |
-
let itemIndex = cart.findIndex(item => item.name === name);
|
179 |
-
if (itemIndex > -1) {
|
180 |
-
cart[itemIndex].quantity += 1;
|
181 |
-
} else {
|
182 |
-
cart.push({ name: name, price: price, quantity: 1 });
|
183 |
-
}
|
184 |
-
alert(name + " added to cart!");
|
185 |
-
}
|
186 |
-
|
187 |
-
function viewCart() {
|
188 |
-
const cartContainer = document.getElementById("cart-container");
|
189 |
-
const cartItemsContainer = document.getElementById("cart-items");
|
190 |
-
|
191 |
-
cartItemsContainer.innerHTML = "";
|
192 |
-
cart.forEach(item => {
|
193 |
-
let div = document.createElement("div");
|
194 |
-
div.classList.add("cart-item");
|
195 |
-
div.innerHTML = `<span>${item.name} (x${item.quantity}) - $${item.price * item.quantity}</span>`;
|
196 |
-
cartItemsContainer.appendChild(div);
|
197 |
-
});
|
198 |
-
|
199 |
-
cartContainer.style.display = "block";
|
200 |
-
}
|
201 |
-
|
202 |
-
function checkout() {
|
203 |
-
if (cart.length > 0) {
|
204 |
-
alert("Your order has been placed successfully!");
|
205 |
-
cart = [];
|
206 |
-
viewCart();
|
207 |
-
} else {
|
208 |
-
alert("Your cart is empty!");
|
209 |
-
}
|
210 |
-
}
|
211 |
-
|
212 |
// ✅ Welcome Message on Page Load
|
213 |
window.onload = askMenuType;
|
214 |
</script>
|
|
|
171 |
});
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
// ✅ Welcome Message on Page Load
|
175 |
window.onload = askMenuType;
|
176 |
</script>
|