Spaces:
Sleeping
Sleeping
Update templates/cart.html
Browse files- templates/cart.html +17 -0
templates/cart.html
CHANGED
@@ -164,6 +164,8 @@
|
|
164 |
</label>
|
165 |
</div>
|
166 |
{% endif %}
|
|
|
|
|
167 |
<button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
|
168 |
</div>
|
169 |
</div>
|
@@ -240,7 +242,22 @@
|
|
240 |
})
|
241 |
.catch(err => console.error("Error:", err));
|
242 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
function calculateSubtotal() {
|
246 |
let subtotal = 0;
|
|
|
164 |
</label>
|
165 |
</div>
|
166 |
{% endif %}
|
167 |
+
<p class="fw-bold" id="discountText">Discount: $0</p>
|
168 |
+
<p class="fw-bold" id="totalBillText">Total Bill: ${{ subtotal }}</p>
|
169 |
<button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
|
170 |
</div>
|
171 |
</div>
|
|
|
242 |
})
|
243 |
.catch(err => console.error("Error:", err));
|
244 |
}
|
245 |
+
function calculateDiscount() {
|
246 |
+
const subtotal = parseFloat("{{ subtotal }}");
|
247 |
+
const discountElement = document.getElementById('discountText');
|
248 |
+
const totalElement = document.getElementById('totalBillText');
|
249 |
+
|
250 |
+
const checkbox = document.getElementById('rewardCheckbox');
|
251 |
+
let discount = 0;
|
252 |
|
253 |
+
if (checkbox.checked) {
|
254 |
+
discount = subtotal * 0.10; // 10% discount if the checkbox is selected
|
255 |
+
}
|
256 |
+
|
257 |
+
// Update the discount and total bill text
|
258 |
+
discountElement.innerText = `Discount: $${discount.toFixed(2)}`;
|
259 |
+
totalElement.innerText = `Total Bill: $${(subtotal - discount).toFixed(2)}`;
|
260 |
+
}
|
261 |
|
262 |
function calculateSubtotal() {
|
263 |
let subtotal = 0;
|