Spaces:
Sleeping
Sleeping
Delete place_order.py
Browse files- place_order.py +0 -38
place_order.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from utils.excel_operations import read_excel, write_excel
|
| 3 |
-
from utils.state_management import state
|
| 4 |
-
import uuid
|
| 5 |
-
|
| 6 |
-
def place_order_page():
|
| 7 |
-
def place_order():
|
| 8 |
-
if not state.get("user"):
|
| 9 |
-
return "Please log in first!"
|
| 10 |
-
|
| 11 |
-
user = state["user"]
|
| 12 |
-
cart = state.get("cart", [])
|
| 13 |
-
if not cart:
|
| 14 |
-
return "Your cart is empty!"
|
| 15 |
-
|
| 16 |
-
orders = read_excel('data/orders.xlsx')
|
| 17 |
-
order_id = str(uuid.uuid4())
|
| 18 |
-
total_cost = sum(item["Price"] * item["Quantity"] for item in cart)
|
| 19 |
-
|
| 20 |
-
new_order = {
|
| 21 |
-
"Order ID": order_id,
|
| 22 |
-
"Customer Email": user["Email"],
|
| 23 |
-
"Table ID": state.get("table_id", "Unknown"),
|
| 24 |
-
"Items": cart,
|
| 25 |
-
"Total Cost": total_cost,
|
| 26 |
-
"Status": "Pending"
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
orders.append(new_order)
|
| 30 |
-
write_excel('data/orders.xlsx', orders)
|
| 31 |
-
|
| 32 |
-
# Clear cart after placing order
|
| 33 |
-
state["cart"] = []
|
| 34 |
-
return f"Order placed successfully! Order ID: {order_id}"
|
| 35 |
-
|
| 36 |
-
with gr.Group():
|
| 37 |
-
gr.Markdown("### Place Your Order")
|
| 38 |
-
gr.Button("Place Order").click(place_order, outputs="Status")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|