Spaces:
Sleeping
Sleeping
Update templates/cart.html
Browse files- templates/cart.html +10 -17
templates/cart.html
CHANGED
@@ -409,24 +409,16 @@
|
|
409 |
|
410 |
|
411 |
function proceedToOrder() {
|
412 |
-
let couponCheckbox = document.getElementById('couponCheckbox');
|
413 |
let couponDropdown = document.getElementById('couponDropdown');
|
414 |
-
let selectedCoupon =
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
// Prevent checkout if no coupon is selected
|
421 |
-
if (!selectedCoupon) {
|
422 |
-
alert("Please select a valid coupon before proceeding.");
|
423 |
-
return;
|
424 |
-
}
|
425 |
-
} else {
|
426 |
-
alert("Error: Coupon dropdown not found.");
|
427 |
-
return;
|
428 |
-
}
|
429 |
}
|
|
|
|
|
430 |
fetch('/checkout', {
|
431 |
method: 'POST',
|
432 |
headers: { 'Content-Type': 'application/json' },
|
@@ -436,7 +428,7 @@
|
|
436 |
.then(data => {
|
437 |
if (data.success) {
|
438 |
alert(data.message);
|
439 |
-
window.location.href = '/order';
|
440 |
} else {
|
441 |
alert(data.error || data.message);
|
442 |
}
|
@@ -444,6 +436,7 @@
|
|
444 |
.catch(err => console.error('Error during checkout:', err));
|
445 |
}
|
446 |
|
|
|
447 |
function calculateSubtotal() {
|
448 |
let subtotal = 0;
|
449 |
document.querySelectorAll('.cart-item').forEach(item => {
|
|
|
409 |
|
410 |
|
411 |
function proceedToOrder() {
|
|
|
412 |
let couponDropdown = document.getElementById('couponDropdown');
|
413 |
+
let selectedCoupon = couponDropdown.value.trim(); // Get selected coupon from the dropdown
|
414 |
+
|
415 |
+
// If no coupon is selected, alert the user
|
416 |
+
if (!selectedCoupon || selectedCoupon === "None") {
|
417 |
+
alert("Please select a valid coupon before proceeding.");
|
418 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
}
|
420 |
+
|
421 |
+
// Send the selected coupon to the backend for processing
|
422 |
fetch('/checkout', {
|
423 |
method: 'POST',
|
424 |
headers: { 'Content-Type': 'application/json' },
|
|
|
428 |
.then(data => {
|
429 |
if (data.success) {
|
430 |
alert(data.message);
|
431 |
+
window.location.href = '/order'; // Redirect to order page
|
432 |
} else {
|
433 |
alert(data.error || data.message);
|
434 |
}
|
|
|
436 |
.catch(err => console.error('Error during checkout:', err));
|
437 |
}
|
438 |
|
439 |
+
|
440 |
function calculateSubtotal() {
|
441 |
let subtotal = 0;
|
442 |
document.querySelectorAll('.cart-item').forEach(item => {
|