Spaces:
Runtime error
Runtime error
Update templates/cart.html
Browse files- templates/cart.html +17 -3
templates/cart.html
CHANGED
|
@@ -202,9 +202,23 @@
|
|
| 202 |
if (data.success) {
|
| 203 |
// Update the item price and quantity in the UI
|
| 204 |
quantityInput.value = quantity;
|
| 205 |
-
let
|
| 206 |
-
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
location.reload();
|
| 209 |
|
| 210 |
// Recalculate subtotal dynamically
|
|
|
|
| 202 |
if (data.success) {
|
| 203 |
// Update the item price and quantity in the UI
|
| 204 |
quantityInput.value = quantity;
|
| 205 |
+
let itemElement = quantityInput.closest(".cart-item"); // Locate the parent cart item
|
| 206 |
+
if (itemElement) {
|
| 207 |
+
let basePriceElement = itemElement.querySelector(".base-price");
|
| 208 |
+
let addonsPriceElement = itemElement.querySelector(".addons-price");
|
| 209 |
+
|
| 210 |
+
// Update the base price
|
| 211 |
+
if (basePriceElement) {
|
| 212 |
+
basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// Update add-ons price if needed (optional)
|
| 216 |
+
if (addonsPriceElement && data.addons_price !== undefined) {
|
| 217 |
+
addonsPriceElement.innerText = data.addons_price.toFixed(2);
|
| 218 |
+
}
|
| 219 |
+
} else {
|
| 220 |
+
console.error(`Parent cart item element not found for item: ${itemName}`);
|
| 221 |
+
}
|
| 222 |
location.reload();
|
| 223 |
|
| 224 |
// Recalculate subtotal dynamically
|