Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,6 +83,10 @@ with gr.Blocks() as demo:
|
|
| 83 |
|
| 84 |
cart_display = gr.HTML(value="<p>Your cart is empty.</p>")
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
gr.HTML("""
|
| 87 |
<div id='cart-icon' style='position: fixed; top: 10px; right: 10px; cursor: pointer;'>
|
| 88 |
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/Shopping_cart_icon.svg/512px-Shopping_cart_icon.svg.png' alt='Cart' style='width: 40px;' onclick='toggleCartPopup()'>
|
|
@@ -138,7 +142,8 @@ with gr.Blocks() as demo:
|
|
| 138 |
method: 'POST',
|
| 139 |
headers: { 'Content-Type': 'application/json' },
|
| 140 |
body: JSON.stringify({ data: [selectedItem, selectedPrice, selectedExtras] })
|
| 141 |
-
}).then(response => response.json()).then(
|
|
|
|
| 142 |
alert(`${selectedItem} has been added to your cart.`);
|
| 143 |
closeMenuPopup();
|
| 144 |
});
|
|
|
|
| 83 |
|
| 84 |
cart_display = gr.HTML(value="<p>Your cart is empty.</p>")
|
| 85 |
|
| 86 |
+
def add_to_cart_handler(item_name, price):
|
| 87 |
+
cart_html = add_item_to_cart(item_name, price)
|
| 88 |
+
return cart_html
|
| 89 |
+
|
| 90 |
gr.HTML("""
|
| 91 |
<div id='cart-icon' style='position: fixed; top: 10px; right: 10px; cursor: pointer;'>
|
| 92 |
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/Shopping_cart_icon.svg/512px-Shopping_cart_icon.svg.png' alt='Cart' style='width: 40px;' onclick='toggleCartPopup()'>
|
|
|
|
| 142 |
method: 'POST',
|
| 143 |
headers: { 'Content-Type': 'application/json' },
|
| 144 |
body: JSON.stringify({ data: [selectedItem, selectedPrice, selectedExtras] })
|
| 145 |
+
}).then(response => response.json()).then(data => {
|
| 146 |
+
document.getElementById('cart-content').innerHTML = data.data[0];
|
| 147 |
alert(`${selectedItem} has been added to your cart.`);
|
| 148 |
closeMenuPopup();
|
| 149 |
});
|