Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -419,16 +419,23 @@ def app():
|
|
419 |
outputs=[login_section, signup_section],
|
420 |
)
|
421 |
# Add item to cart logic
|
422 |
-
def add_item_to_cart(
|
423 |
-
|
|
|
424 |
return cart
|
425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
# Navigation from "View Cart" button to Cart Page
|
427 |
def display_cart(cart):
|
428 |
if not cart:
|
429 |
return "Your cart is empty.", ""
|
430 |
cart_html = "<ul>" + "".join(f"<li>{item}</li>" for item in cart) + "</ul>"
|
431 |
-
final_html = f"<p>
|
432 |
return cart_html, final_html
|
433 |
|
434 |
view_cart_button.click(
|
@@ -442,6 +449,7 @@ def app():
|
|
442 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
443 |
outputs=[menu_section, cart_section],
|
444 |
)
|
|
|
445 |
return demo
|
446 |
|
447 |
|
|
|
419 |
outputs=[login_section, signup_section],
|
420 |
)
|
421 |
# Add item to cart logic
|
422 |
+
def add_item_to_cart(cart):
|
423 |
+
item = "Sample Item" # Simulate an item being added
|
424 |
+
cart.append(item)
|
425 |
return cart
|
426 |
|
427 |
+
add_item_button.click(
|
428 |
+
add_item_to_cart,
|
429 |
+
inputs=[cart_state],
|
430 |
+
outputs=[cart_state],
|
431 |
+
)
|
432 |
+
|
433 |
# Navigation from "View Cart" button to Cart Page
|
434 |
def display_cart(cart):
|
435 |
if not cart:
|
436 |
return "Your cart is empty.", ""
|
437 |
cart_html = "<ul>" + "".join(f"<li>{item}</li>" for item in cart) + "</ul>"
|
438 |
+
final_html = f"<p>Total items: {len(cart)}</p>"
|
439 |
return cart_html, final_html
|
440 |
|
441 |
view_cart_button.click(
|
|
|
449 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
450 |
outputs=[menu_section, cart_section],
|
451 |
)
|
452 |
+
|
453 |
return demo
|
454 |
|
455 |
|