Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -174,7 +174,7 @@ modal_and_cart_js = """
|
|
| 174 |
updateCartDisplay();
|
| 175 |
closeModal();
|
| 176 |
}
|
| 177 |
-
|
| 178 |
let totalBill = 0;
|
| 179 |
let cartHTML = "<div class='cart-container'>";
|
| 180 |
cart.forEach((item, index) => {
|
|
@@ -191,7 +191,7 @@ modal_and_cart_js = """
|
|
| 191 |
<input type='number' id='extra-quantity-${index}-${i}' value='${extraQuantity}' min='1' style='width: 50px;' onchange='updateExtraQuantity(${index}, ${i}, this.value)'>
|
| 192 |
</div>
|
| 193 |
<span>Total: $${extraTotal.toFixed(2)}</span>
|
| 194 |
-
<
|
| 195 |
</div>`;
|
| 196 |
}).join('');
|
| 197 |
cartHTML += `<div class='cart-item'>
|
|
@@ -202,15 +202,16 @@ modal_and_cart_js = """
|
|
| 202 |
<input type='number' id='item-quantity-${index}' value='${item.quantity}' min='1' style='width: 50px;' onchange='updateItemQuantity(${index}, this.value)'>
|
| 203 |
</div>
|
| 204 |
<span>Total: $${(item.price * item.quantity).toFixed(2)}</span>
|
| 205 |
-
<
|
| 206 |
-
|
| 207 |
${extras}
|
| 208 |
<div class='cart-item'><strong>Instructions:</strong> ${item.instructions || "None"}</div>`;
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
|
|
|
| 214 |
function updateItemQuantity(index, newQuantity) {
|
| 215 |
const quantity = parseInt(newQuantity) || 1;
|
| 216 |
cart[index].quantity = quantity;
|
|
|
|
| 174 |
updateCartDisplay();
|
| 175 |
closeModal();
|
| 176 |
}
|
| 177 |
+
function updateCartDisplay() {
|
| 178 |
let totalBill = 0;
|
| 179 |
let cartHTML = "<div class='cart-container'>";
|
| 180 |
cart.forEach((item, index) => {
|
|
|
|
| 191 |
<input type='number' id='extra-quantity-${index}-${i}' value='${extraQuantity}' min='1' style='width: 50px;' onchange='updateExtraQuantity(${index}, ${i}, this.value)'>
|
| 192 |
</div>
|
| 193 |
<span>Total: $${extraTotal.toFixed(2)}</span>
|
| 194 |
+
<button style='background-color: red; color: white; border: none; padding: 5px 10px; cursor: pointer;' onclick='removeExtra(${index}, ${i})'>Remove</button>
|
| 195 |
</div>`;
|
| 196 |
}).join('');
|
| 197 |
cartHTML += `<div class='cart-item'>
|
|
|
|
| 202 |
<input type='number' id='item-quantity-${index}' value='${item.quantity}' min='1' style='width: 50px;' onchange='updateItemQuantity(${index}, this.value)'>
|
| 203 |
</div>
|
| 204 |
<span>Total: $${(item.price * item.quantity).toFixed(2)}</span>
|
| 205 |
+
<button style='background-color: red; color: white; border: none; padding: 5px 10px; cursor: pointer;' onclick='removeItem(${index})'>Remove</button>
|
| 206 |
+
</div>
|
| 207 |
${extras}
|
| 208 |
<div class='cart-item'><strong>Instructions:</strong> ${item.instructions || "None"}</div>`;
|
| 209 |
+
});
|
| 210 |
+
cartHTML += `</div><p class='cart-total'>Total Bill: $${totalBill.toFixed(2)}</p>`;
|
| 211 |
+
cartHTML += `<button style='margin-top: 10px; background-color: #007bff; color: white; border: none; padding: 10px; border-radius: 5px; width: 100%; cursor: pointer;' onclick='submitCart()'>Submit</button>`;
|
| 212 |
+
document.getElementById('floating-cart').innerHTML = cartHTML;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
function updateItemQuantity(index, newQuantity) {
|
| 216 |
const quantity = parseInt(newQuantity) || 1;
|
| 217 |
cart[index].quantity = quantity;
|