Spaces:
Sleeping
Sleeping
Update templates/Menu.html
Browse files- templates/Menu.html +9 -8
templates/Menu.html
CHANGED
|
@@ -261,17 +261,18 @@
|
|
| 261 |
}
|
| 262 |
|
| 263 |
// Display menu items on the page
|
| 264 |
-
function
|
| 265 |
const menuContainer = document.getElementById("menu");
|
| 266 |
menuContainer.innerHTML = '';
|
| 267 |
|
| 268 |
-
|
| 269 |
const menuItem = document.createElement("div");
|
| 270 |
menuItem.classList.add("menu-item");
|
| 271 |
menuItem.innerHTML = `
|
| 272 |
<div class="menu-details">
|
| 273 |
<h3>${item.Name}</h3>
|
| 274 |
<p class="price">$${item.Price__c}</p>
|
|
|
|
| 275 |
</div>
|
| 276 |
<div class="add-container">
|
| 277 |
<img class="menu-img" src="${item.Image1__c}" alt="${item.Name}">
|
|
@@ -281,7 +282,7 @@
|
|
| 281 |
<span>${cart[item.Name].quantity}</span>
|
| 282 |
<button onclick="increaseQuantity('${item.Name}')">+</button>
|
| 283 |
</div>`
|
| 284 |
-
: `<button class="add-btn" onclick=
|
| 285 |
<p class="customizable" style="text-align: center; margin-top: 10px;">Customisable</p>
|
| 286 |
</div>
|
| 287 |
`;
|
|
@@ -308,13 +309,13 @@
|
|
| 308 |
});
|
| 309 |
|
| 310 |
// Function to handle adding an item to the cart
|
| 311 |
-
function addToCart(
|
| 312 |
-
if (cart[
|
| 313 |
-
cart[
|
| 314 |
} else {
|
| 315 |
-
cart[
|
| 316 |
}
|
| 317 |
-
|
| 318 |
}
|
| 319 |
|
| 320 |
// Function to increase quantity
|
|
|
|
| 261 |
}
|
| 262 |
|
| 263 |
// Display menu items on the page
|
| 264 |
+
function displayMenu(menuItems) {
|
| 265 |
const menuContainer = document.getElementById("menu");
|
| 266 |
menuContainer.innerHTML = '';
|
| 267 |
|
| 268 |
+
menuItems.forEach(item => {
|
| 269 |
const menuItem = document.createElement("div");
|
| 270 |
menuItem.classList.add("menu-item");
|
| 271 |
menuItem.innerHTML = `
|
| 272 |
<div class="menu-details">
|
| 273 |
<h3>${item.Name}</h3>
|
| 274 |
<p class="price">$${item.Price__c}</p>
|
| 275 |
+
<p class="description">${item.Description__c}</p>
|
| 276 |
</div>
|
| 277 |
<div class="add-container">
|
| 278 |
<img class="menu-img" src="${item.Image1__c}" alt="${item.Name}">
|
|
|
|
| 282 |
<span>${cart[item.Name].quantity}</span>
|
| 283 |
<button onclick="increaseQuantity('${item.Name}')">+</button>
|
| 284 |
</div>`
|
| 285 |
+
: `<button class="add-btn" onclick='addToCart(${JSON.stringify(item)})'>ADD</button>`}
|
| 286 |
<p class="customizable" style="text-align: center; margin-top: 10px;">Customisable</p>
|
| 287 |
</div>
|
| 288 |
`;
|
|
|
|
| 309 |
});
|
| 310 |
|
| 311 |
// Function to handle adding an item to the cart
|
| 312 |
+
function addToCart(item.Name, proce, image) {
|
| 313 |
+
if (cart[item.Name]) {
|
| 314 |
+
cart[item.Name].quantity += 1;
|
| 315 |
} else {
|
| 316 |
+
cart[item.Name] = { ...item, quantity: 1 };
|
| 317 |
}
|
| 318 |
+
displayMenu(filteredMenu); // Refresh menu UI to update button
|
| 319 |
}
|
| 320 |
|
| 321 |
// Function to increase quantity
|