Spaces:
Sleeping
Sleeping
Update templates/cart.html
Browse files- templates/cart.html +16 -10
templates/cart.html
CHANGED
@@ -256,6 +256,11 @@
|
|
256 |
})
|
257 |
.catch(err => console.error("Error:", err));
|
258 |
}
|
|
|
|
|
|
|
|
|
|
|
259 |
function calculateDiscount() {
|
260 |
const subtotal = parseFloat("{{ subtotal }}");
|
261 |
const discountElement = document.getElementById('discountText');
|
@@ -286,26 +291,27 @@
|
|
286 |
document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
|
287 |
return subtotal;
|
288 |
}
|
289 |
-
|
290 |
-
|
291 |
function proceedToOrder() {
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
|
299 |
fetch('/checkout', {
|
300 |
method: 'POST',
|
301 |
headers: { 'Content-Type': 'application/json' },
|
302 |
-
body: JSON.stringify({
|
|
|
|
|
|
|
303 |
})
|
304 |
.then(response => response.json())
|
305 |
.then(data => {
|
306 |
if (data.success) {
|
307 |
alert(data.message);
|
308 |
-
window.location.href = '/order'; // Redirect to
|
309 |
} else {
|
310 |
alert(data.error || data.message);
|
311 |
}
|
|
|
256 |
})
|
257 |
.catch(err => console.error("Error:", err));
|
258 |
}
|
259 |
+
function toggleCouponDropdown() {
|
260 |
+
let couponCheckbox = document.getElementById('couponCheckbox');
|
261 |
+
let couponDropdown = document.getElementById('couponDropdown');
|
262 |
+
couponDropdown.disabled = !couponCheckbox.checked;
|
263 |
+
}
|
264 |
function calculateDiscount() {
|
265 |
const subtotal = parseFloat("{{ subtotal }}");
|
266 |
const discountElement = document.getElementById('discountText');
|
|
|
291 |
document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
|
292 |
return subtotal;
|
293 |
}
|
|
|
|
|
294 |
function proceedToOrder() {
|
295 |
+
const rewardCheckbox = document.getElementById('rewardCheckbox');
|
296 |
+
let useRewardPoints = rewardCheckbox ? rewardCheckbox.checked : false;
|
297 |
+
|
298 |
+
const couponCheckbox = document.getElementById('couponCheckbox');
|
299 |
+
const couponDropdown = document.getElementById('couponDropdown');
|
300 |
+
let selectedCoupon = couponCheckbox.checked ? couponDropdown.value : "";
|
301 |
|
302 |
fetch('/checkout', {
|
303 |
method: 'POST',
|
304 |
headers: { 'Content-Type': 'application/json' },
|
305 |
+
body: JSON.stringify({
|
306 |
+
useRewardPoints: useRewardPoints,
|
307 |
+
selectedCoupon: selectedCoupon // Send selected coupon to backend
|
308 |
+
})
|
309 |
})
|
310 |
.then(response => response.json())
|
311 |
.then(data => {
|
312 |
if (data.success) {
|
313 |
alert(data.message);
|
314 |
+
window.location.href = '/order'; // Redirect to order confirmation
|
315 |
} else {
|
316 |
alert(data.error || data.message);
|
317 |
}
|