Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -58,25 +58,25 @@ def update_cart():
|
|
58 |
return "Your cart is empty."
|
59 |
|
60 |
total_bill = 0
|
61 |
-
cart_html = "<h3>Your Cart:</h3><
|
62 |
-
cart_html += "<tr><th style='border: 1px solid black; padding: 8px;'>Selected Item</th><th style='border: 1px solid black; padding: 8px;'>Actual Price</th><th style='border: 1px solid black; padding: 8px;'>Quantity x Price</th><th style='border: 1px solid black; padding: 8px;'>Spice Level</th><th style='border: 1px solid black; padding: 8px;'>Extras</th><th style='border: 1px solid black; padding: 8px;'>Instructions</th></tr>"
|
63 |
|
64 |
for item in cart_items:
|
65 |
extras = ", ".join(item.get("extras", []))
|
66 |
extras_cost = sum(EXTRAS_PRICES.get(extra, 0) for extra in item.get("extras", []))
|
67 |
-
|
|
|
68 |
total_bill += item_total
|
69 |
-
|
70 |
-
cart_html += f"<
|
71 |
-
cart_html += f"<
|
72 |
-
cart_html += f"<
|
73 |
-
cart_html += f"<
|
74 |
-
cart_html += f"<
|
75 |
-
cart_html += f"<
|
76 |
-
cart_html += f"
|
77 |
-
|
78 |
-
|
79 |
-
cart_html += f"
|
80 |
return cart_html
|
81 |
|
82 |
# Gradio app definition
|
|
|
58 |
return "Your cart is empty."
|
59 |
|
60 |
total_bill = 0
|
61 |
+
cart_html = "<h3>Your Cart:</h3><ul style='list-style-type: none; padding: 0;'>"
|
|
|
62 |
|
63 |
for item in cart_items:
|
64 |
extras = ", ".join(item.get("extras", []))
|
65 |
extras_cost = sum(EXTRAS_PRICES.get(extra, 0) for extra in item.get("extras", []))
|
66 |
+
item_price = float(item['price'].strip('$'))
|
67 |
+
item_total = (item_price + extras_cost) * item['quantity']
|
68 |
total_bill += item_total
|
69 |
+
|
70 |
+
cart_html += f"<li style='margin-bottom: 20px; border: 1px solid #ddd; padding: 10px; border-radius: 8px;'>"
|
71 |
+
cart_html += f"<strong>Item:</strong> {item['name']} - ${item_price:.2f}<br>"
|
72 |
+
cart_html += f"<strong>Quantity x Price:</strong> {item['quantity']} x ${item_price:.2f} = ${item_price * item['quantity']:.2f}<br>"
|
73 |
+
cart_html += f"<strong>Spice Level:</strong> {item['spiceLevel']}<br>"
|
74 |
+
cart_html += f"<strong>Extras:</strong> {extras} - ${extras_cost:.2f}<br>"
|
75 |
+
cart_html += f"<strong>Instructions:</strong> {item['instructions']}<br>"
|
76 |
+
cart_html += f"<strong>Item Total:</strong> ${item_total:.2f}"
|
77 |
+
cart_html += "</li>"
|
78 |
+
|
79 |
+
cart_html += f"</ul><p><strong>Total Bill: ${total_bill:.2f}</strong></p>"
|
80 |
return cart_html
|
81 |
|
82 |
# Gradio app definition
|