Spaces:
Build error
Build error
Update app.py
Browse files78 unmodified lines79808182838485868788899091929394959697989910010110210310410510610710810911012 unmodified lines123124125126127128129130131132133134135112 unmodified lines24824925025125225325425578 unmodified lines cart_html += f"</ul><p><strong>Total Bill: ${total_bill:.2f}</strong></p>" return cart_html
# Function to submit the cart and display on a new pagedef submit_cart(): if len(cart_items) == 0: return "<h3>Your Order</h3><p>Your cart is empty.</p>"
total_bill = 0 order_html = "<h3>Your Order</h3><ul style='list-style-type: none; padding: 0;'>" for item in cart_items: extras = ", ".join(item.get("extras", [])) extras_cost = sum(EXTRAS_PRICES.get(extra, 0) for extra in item.get("extras", [])) item_price = float(item['price'].strip('$')) item_total = (item_price + extras_cost) * item['quantity'] total_bill += item_total
order_html += f"<li style='margin-bottom: 20px; border: 1px solid #ddd; padding: 10px; border-radius: 8px;'>" order_html += f"<strong>Item:</strong> {item['name']} - ${item_price:.2f}<br>" order_html += f"<strong>Quantity x Price:</strong> {item['quantity']} x ${item_price:.2f} = ${item_price * item['quantity']:.2f}<br>" order_html += f"<strong>Spice Level:</strong> {item['spiceLevel']}<br>" order_html += f"<strong>Extras:</strong> {extras} - ${extras_cost:.2f}<br>" order_html += f"<strong>Instructions:</strong> {item['instructions']}<br>" order_html += f"<strong>Item Total:</strong> ${item_total:.2f}" order_html += "</li>"
order_html += f"</ul><p><strong>Total Bill: ${total_bill:.2f}</strong></p>" return order_html
# Gradio app definitiondef app(): with gr.Blocks() as demo:12 unmodified lines # Floating cart display cart_output = gr.HTML(value=update_cart(), elem_id="floating-cart")
# Submit button for the cart submit_button = gr.Button("Submit Order") order_page = gr.HTML(value="")
# Submit button action submit_button.click(fn=submit_cart, inputs=[], outputs=order_page)
# JavaScript for modal and cart behavior modal_and_cart_js = """ <script>112 unmodified lines gr.Row([selected_preference]) gr.Row(menu_output) gr.Row(cart_output) gr.Row([submit_button]) gr.Row(order_page) gr.Row(modal_window) gr.HTML(modal_and_cart_js)
app.py+35