nagasurendra commited on
Commit
8c641cf
·
verified ·
1 Parent(s): 70c8159

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
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><table style='border: 1px solid black; border-collapse: collapse; width: 100%;'>"
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
- item_total = (float(item['price'].strip('$')) + extras_cost) * item['quantity']
 
68
  total_bill += item_total
69
- cart_html += f"<tr>"
70
- cart_html += f"<td style='border: 1px solid black; padding: 8px;'>{item['name']}</td>"
71
- cart_html += f"<td style='border: 1px solid black; padding: 8px;'>${float(item['price'].strip('$')):.2f}</td>"
72
- cart_html += f"<td style='border: 1px solid black; padding: 8px;'>${item_total:.2f}</td>"
73
- cart_html += f"<td style='border: 1px solid black; padding: 8px;'>{item['spiceLevel']}</td>"
74
- cart_html += f"<td style='border: 1px solid black; padding: 8px;'>{extras}</td>"
75
- cart_html += f"<td style='border: 1px solid black; padding: 8px;'>{item['instructions']}</td>"
76
- cart_html += f"</tr>"
77
-
78
- cart_html += "</table>"
79
- cart_html += f"<p><strong>Total Bill: ${total_bill:.2f}</strong></p>"
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