nagasurendra commited on
Commit
ba38de0
·
verified ·
1 Parent(s): cf6db7d

Update templates/cart.html

Browse files
Files changed (1) hide show
  1. templates/cart.html +14 -5
templates/cart.html CHANGED
@@ -297,13 +297,22 @@
297
  function proceedToOrder() {
298
  let couponCheckbox = document.getElementById('couponCheckbox');
299
  let couponDropdown = document.getElementById('couponDropdown');
300
- let selectedCoupon = couponCheckbox.checked ? couponDropdown.value.trim() : "";
301
 
302
- if (couponCheckbox.checked && (!selectedCoupon || selectedCoupon.toLowerCase() === "none")) {
303
- alert("Please select a valid coupon before proceeding.");
304
- return;
 
 
 
 
 
 
 
 
 
 
305
  }
306
-
307
  fetch('/checkout', {
308
  method: 'POST',
309
  headers: { 'Content-Type': 'application/json' },
 
297
  function proceedToOrder() {
298
  let couponCheckbox = document.getElementById('couponCheckbox');
299
  let couponDropdown = document.getElementById('couponDropdown');
300
+ let selectedCoupon = ""; // Default to empty coupon
301
 
302
+ if (couponCheckbox && couponCheckbox.checked) {
303
+ if (couponDropdown) {
304
+ selectedCoupon = couponDropdown.value.trim();
305
+
306
+ // Prevent checkout if no coupon is selected
307
+ if (!selectedCoupon) {
308
+ alert("Please select a valid coupon before proceeding.");
309
+ return;
310
+ }
311
+ } else {
312
+ alert("Error: Coupon dropdown not found.");
313
+ return;
314
+ }
315
  }
 
316
  fetch('/checkout', {
317
  method: 'POST',
318
  headers: { 'Content-Type': 'application/json' },