nagasurendra commited on
Commit
7ee2a9e
·
verified ·
1 Parent(s): 849e208

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -20
app.py CHANGED
@@ -196,26 +196,35 @@ modal_and_cart_js = """
196
  updateCartDisplay();
197
  }
198
  function submitCart() {
199
- let finalOrderHTML = "<h3>Final Order:</h3><ul>";
200
- let totalBill = 0;
201
- cart.forEach(item => {
202
- totalBill += item.itemTotal;
203
- const extras = item.extras.map((extra, i) => {
204
- const extraQuantity = item.extrasQuantities ? item.extrasQuantities[i] || 1 : 1;
205
- const extraTotal = extrasPrices[extra] * extraQuantity;
206
- totalBill += extraTotal;
207
- return `${extra} (x${extraQuantity}) - $${extraTotal.toFixed(2)}`;
208
- }).join(', ');
209
- finalOrderHTML += `<li>
210
- ${item.name} (x${item.quantity}) - $${item.itemTotal.toFixed(2)}
211
- <br>Extras: ${extras}
212
- <br>Instructions: ${item.instructions || "None"}
213
- </li>`;
214
- });
215
- finalOrderHTML += `</ul><p><strong>Total Bill: $${totalBill.toFixed(2)}</strong></p>`;
216
- document.getElementById('final-order').innerHTML = finalOrderHTML;
217
- alert("Your final order has been submitted!");
218
- }
 
 
 
 
 
 
 
 
 
219
  </script>
220
  """
221
 
 
196
  updateCartDisplay();
197
  }
198
  function submitCart() {
199
+ let finalOrderHTML = "<h3>Final Order:</h3><ul>";
200
+ let totalBill = 0;
201
+
202
+ // Generate final order summary
203
+ cart.forEach(item => {
204
+ totalBill += item.itemTotal;
205
+ const extras = item.extras.map((extra, i) => {
206
+ const extraQuantity = item.extrasQuantities ? item.extrasQuantities[i] || 1 : 1;
207
+ const extraTotal = extrasPrices[extra] * extraQuantity;
208
+ totalBill += extraTotal;
209
+ return `${extra} (x${extraQuantity}) - $${extraTotal.toFixed(2)}`;
210
+ }).join(', ');
211
+
212
+ finalOrderHTML += `<li>
213
+ ${item.name} (x${item.quantity}) - $${item.itemTotal.toFixed(2)}
214
+ <br>Extras: ${extras}
215
+ <br>Instructions: ${item.instructions || "None"}
216
+ </li>`;
217
+ });
218
+
219
+ finalOrderHTML += `</ul><p><strong>Total Bill: $${totalBill.toFixed(2)}</strong></p>`;
220
+
221
+ // Store order summary in session storage for next page
222
+ sessionStorage.setItem('finalOrderSummary', finalOrderHTML);
223
+
224
+ // Redirect to the final order page
225
+ window.location.href = "/final_order.html"; // Ensure this page exists
226
+ }
227
+
228
  </script>
229
  """
230