Spaces:
Sleeping
Sleeping
Update components/cart.py
Browse files- components/cart.py +13 -13
components/cart.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
cart = [] #
|
2 |
|
3 |
-
def add_to_cart(dish_name, spice_level, extras, instructions, quantity
|
4 |
-
"""Add selected item
|
5 |
-
|
6 |
-
price = dish['Price']
|
7 |
-
extras_cost = sum([float(extra.split('+ $')[-1]) for extra in extras]) if extras else 0
|
8 |
-
total_price = (price + extras_cost) * quantity
|
9 |
-
|
10 |
-
# Add to cart
|
11 |
-
cart.append({
|
12 |
"Dish": dish_name,
|
13 |
"Spice Level": spice_level,
|
14 |
"Extras": ", ".join(extras) if extras else "None",
|
15 |
"Instructions": instructions,
|
16 |
"Quantity": quantity,
|
17 |
-
"Price": f"${
|
18 |
-
}
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cart = [] # Global cart
|
2 |
|
3 |
+
def add_to_cart(dish_name, spice_level, extras, instructions, quantity):
|
4 |
+
"""Add selected item to the cart."""
|
5 |
+
item = {
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
"Dish": dish_name,
|
7 |
"Spice Level": spice_level,
|
8 |
"Extras": ", ".join(extras) if extras else "None",
|
9 |
"Instructions": instructions,
|
10 |
"Quantity": quantity,
|
11 |
+
"Price": f"${(quantity * 10.0):.2f}" # Example price
|
12 |
+
}
|
13 |
+
cart.append(item)
|
14 |
+
return cart_data()
|
15 |
+
|
16 |
+
def cart_data():
|
17 |
+
"""Return cart data."""
|
18 |
+
import pandas as pd
|
19 |
+
return pd.DataFrame(cart)
|