Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -119,7 +119,7 @@ def create_modal_window():
|
|
119 |
for add_on in add_ons:
|
120 |
add_ons_html += f"""
|
121 |
<label>
|
122 |
-
<input type="
|
123 |
{add_on['Name']} + ${add_on['Price__c']}
|
124 |
</label>
|
125 |
"""
|
@@ -177,12 +177,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"]
|
181 |
-
name: extra.
|
182 |
-
price: parseFloat(extra.getAttribute('data-price')
|
|
|
183 |
}));
|
184 |
-
const extrasCost = extras.reduce((total, extra) => total + extra.price, 0);
|
185 |
-
const totalCost = (price
|
186 |
|
187 |
// Add the item to the cart
|
188 |
cart.push({ name, price, quantity, extras, instructions, totalCost });
|
@@ -203,7 +204,7 @@ def modal_js():
|
|
203 |
cartItemsContainer.innerHTML = "";
|
204 |
|
205 |
cart.forEach((item, index) => {
|
206 |
-
const extrasList = item.extras.map(extra => `${extra.name} (+$${extra.price.toFixed(2)})`).join(', ');
|
207 |
cartItemsContainer.innerHTML += `
|
208 |
<div style="border: 1px solid #ddd; padding: 10px; margin-bottom: 10px; border-radius: 8px;">
|
209 |
<h3>${item.name}</h3>
|
|
|
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 |
"""
|
|
|
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
|
189 |
cart.push({ name, price, quantity, extras, instructions, totalCost });
|
|
|
204 |
cartItemsContainer.innerHTML = "";
|
205 |
|
206 |
cart.forEach((item, index) => {
|
207 |
+
const extrasList = item.extras.map(extra => `${extra.name} x${extra.quantity} (+$${(extra.price * extra.quantity).toFixed(2)})`).join(', ');
|
208 |
cartItemsContainer.innerHTML += `
|
209 |
<div style="border: 1px solid #ddd; padding: 10px; margin-bottom: 10px; border-radius: 8px;">
|
210 |
<h3>${item.name}</h3>
|