Spaces:
Build error
Build error
Update templates/cart.html
Browse files- templates/cart.html +12 -13
templates/cart.html
CHANGED
|
@@ -389,25 +389,24 @@
|
|
| 389 |
let couponDropdown = document.getElementById('couponDropdown');
|
| 390 |
let subtotal = parseFloat("{{ subtotal }}");
|
| 391 |
|
| 392 |
-
//
|
| 393 |
let selectedCoupon = couponDropdown.value.trim();
|
| 394 |
-
|
| 395 |
-
|
|
|
|
| 396 |
document.getElementById("discountText").innerText = `Discount: $0`;
|
| 397 |
document.getElementById("totalBillText").innerText = `Total Bill: $${subtotal.toFixed(2)}`;
|
| 398 |
-
|
| 399 |
-
|
|
|
|
|
|
|
| 400 |
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
// Update the UI with discount and new total
|
| 406 |
-
document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
|
| 407 |
-
document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
|
| 408 |
}
|
| 409 |
|
| 410 |
-
|
| 411 |
function proceedToOrder() {
|
| 412 |
let couponCheckbox = document.getElementById('couponCheckbox');
|
| 413 |
let couponDropdown = document.getElementById('couponDropdown');
|
|
|
|
| 389 |
let couponDropdown = document.getElementById('couponDropdown');
|
| 390 |
let subtotal = parseFloat("{{ subtotal }}");
|
| 391 |
|
| 392 |
+
// Check if a coupon is selected
|
| 393 |
let selectedCoupon = couponDropdown.value.trim();
|
| 394 |
+
|
| 395 |
+
if (!selectedCoupon || selectedCoupon === "") {
|
| 396 |
+
// No coupon selected, reset the discount and total to the original values
|
| 397 |
document.getElementById("discountText").innerText = `Discount: $0`;
|
| 398 |
document.getElementById("totalBillText").innerText = `Total Bill: $${subtotal.toFixed(2)}`;
|
| 399 |
+
} else {
|
| 400 |
+
// Apply a 10% discount (or your desired logic here)
|
| 401 |
+
let discount = subtotal * 0.10;
|
| 402 |
+
let total = subtotal - discount;
|
| 403 |
|
| 404 |
+
// Update the UI with discount and new total
|
| 405 |
+
document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
|
| 406 |
+
document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
|
| 407 |
+
}
|
|
|
|
|
|
|
|
|
|
| 408 |
}
|
| 409 |
|
|
|
|
| 410 |
function proceedToOrder() {
|
| 411 |
let couponCheckbox = document.getElementById('couponCheckbox');
|
| 412 |
let couponDropdown = document.getElementById('couponDropdown');
|