nagasurendra commited on
Commit
fe811c2
·
verified ·
1 Parent(s): 170c808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -206,7 +206,7 @@ def modal_js():
206
  cartItemsContainer.innerHTML = "";
207
 
208
  cart.forEach((item, index) => {
209
- const extrasList = item.extras.map(extra => `${extra.name} x${extra.quantity} (+$${(extra.price * extra.quantity).toFixed(2)})`).join(', ');
210
  cartItemsContainer.innerHTML += `
211
  <div style="border: 1px solid #ddd; padding: 10px; margin-bottom: 10px; border-radius: 8px;">
212
  <h3>${item.name}</h3>
@@ -237,7 +237,10 @@ def modal_js():
237
  function updateCartItem(index, type, value) {
238
  if (type === 'item') {
239
  cart[index].quantity = parseInt(value);
 
 
240
  }
 
241
  const item = cart[index];
242
  const price = item.price;
243
  const extrasCost = item.extras.reduce((total, extra) => total + (extra.price * extra.quantity), 0);
 
206
  cartItemsContainer.innerHTML = "";
207
 
208
  cart.forEach((item, index) => {
209
+ const extrasList = item.extras.map(extra => `${extra.name} x<input type="number" value="${extra.quantity}" min="1" style="width: 50px;" onchange="updateCartItem(${index}, 'extra', this.value)" /> (+$${(extra.price * extra.quantity).toFixed(2)})`).join(', ');
210
  cartItemsContainer.innerHTML += `
211
  <div style="border: 1px solid #ddd; padding: 10px; margin-bottom: 10px; border-radius: 8px;">
212
  <h3>${item.name}</h3>
 
237
  function updateCartItem(index, type, value) {
238
  if (type === 'item') {
239
  cart[index].quantity = parseInt(value);
240
+ } else if (type === 'extra') {
241
+ cart[index].extras[0].quantity = parseInt(value); // Assuming one add-on for simplicity
242
  }
243
+
244
  const item = cart[index];
245
  const price = item.price;
246
  const extrasCost = item.extras.reduce((total, extra) => total + (extra.price * extra.quantity), 0);