nagasurendra commited on
Commit
f6df108
·
verified ·
1 Parent(s): ac0743c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -119,9 +119,10 @@ def create_modal_window():
119
  for add_on in add_ons:
120
  add_ons_html += f"""
121
  <label>
122
- <input type="number" name="biryani-extra-quantity" value="1" min="1" style="width: 50px;" data-name="{add_on['Name']}" data-price="{add_on['Price__c']}" />
123
  {add_on['Name']} + ${add_on['Price__c']}
124
  </label>
 
125
  """
126
 
127
  modal_html = f"""
@@ -177,12 +178,13 @@ def modal_js():
177
  const price = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
178
  const quantity = parseInt(document.getElementById('quantity').value) || 1;
179
  const instructions = document.getElementById('special-instructions').value;
180
- const extras = Array.from(document.querySelectorAll('input[name="biryani-extra-quantity"]')).map(extra => ({
181
- name: extra.getAttribute('data-name'),
 
182
  price: parseFloat(extra.getAttribute('data-price')),
183
- quantity: parseInt(extra.value)
184
  }));
185
- const extrasCost = extras.reduce((total, extra) => total + extra.price * extra.quantity, 0);
186
  const totalCost = (price * quantity) + extrasCost;
187
 
188
  // Add the item to the cart
 
119
  for add_on in add_ons:
120
  add_ons_html += f"""
121
  <label>
122
+ <input type="checkbox" name="biryani-extra" value="{add_on['Name']}" data-price="{add_on['Price__c']}" />
123
  {add_on['Name']} + ${add_on['Price__c']}
124
  </label>
125
+ <br>
126
  """
127
 
128
  modal_html = f"""
 
178
  const price = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
179
  const quantity = parseInt(document.getElementById('quantity').value) || 1;
180
  const instructions = document.getElementById('special-instructions').value;
181
+ const selectedAddOns = Array.from(document.querySelectorAll('input[name="biryani-extra"]:checked'));
182
+ const extras = selectedAddOns.map(extra => ({
183
+ name: extra.value,
184
  price: parseFloat(extra.getAttribute('data-price')),
185
+ quantity: 1 // Default quantity for add-ons is 1
186
  }));
187
+ const extrasCost = extras.reduce((total, extra) => total + (extra.price * extra.quantity), 0);
188
  const totalCost = (price * quantity) + extrasCost;
189
 
190
  // Add the item to the cart