Spaces:
Sleeping
Sleeping
cart = [] # Store all cart items | |
def add_to_cart(dish_name, spice_level, extras, instructions, quantity, menu_data): | |
"""Add selected item with options to the cart.""" | |
dish = menu_data[menu_data['Dish Name'] == dish_name].iloc[0] | |
price = dish['Price'] | |
extras_cost = sum([float(extra.split('+ $')[-1]) for extra in extras]) if extras else 0 | |
total_price = (price + extras_cost) * quantity | |
# Add to cart | |
cart.append({ | |
"Dish": dish_name, | |
"Spice Level": spice_level, | |
"Extras": ", ".join(extras) if extras else "None", | |
"Instructions": instructions, | |
"Quantity": quantity, | |
"Price": f"${total_price:.2f}" | |
}) | |
return cart | |