Update templates/cart.html (#5)
Browse files- Update templates/cart.html (b410bbdfd8674e82a4f5adddb494868bfbc48ba5)
Co-authored-by: lokesh surya sai sirigineedi <[email protected]>
- templates/cart.html +63 -51
templates/cart.html
CHANGED
@@ -10,23 +10,39 @@
|
|
10 |
|
11 |
body {
|
12 |
font-family: Arial, sans-serif;
|
13 |
-
background-color:
|
14 |
color: #333;
|
15 |
}
|
16 |
.cart-container {
|
17 |
max-width: 768px;
|
18 |
margin: 20px auto;
|
19 |
padding: 15px;
|
20 |
-
background-color: #
|
21 |
border-radius: 10px;
|
|
|
22 |
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
23 |
}
|
24 |
.cart-container2 {
|
25 |
-
background-color
|
26 |
}
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
display: flex;
|
31 |
align-items: flex-start;
|
32 |
justify-content: space-between;
|
@@ -36,8 +52,9 @@
|
|
36 |
box-sizing: border-box;
|
37 |
min-height: 100px;
|
38 |
position: relative; /* Make the cart item a reference for the absolute positioning of the remove icon */
|
|
|
|
|
39 |
}
|
40 |
-
|
41 |
.remove-btn {
|
42 |
border: none; /* Remove the border around the button */
|
43 |
background-color: transparent; /* Transparent background */
|
@@ -49,12 +66,9 @@
|
|
49 |
top: -35px; /* Move the button 10px upwards */
|
50 |
left: 50px; /* Move the button 30px to the right */
|
51 |
}
|
52 |
-
|
53 |
.remove-btn i {
|
54 |
color: red; /* Make the trash icon red */
|
55 |
}
|
56 |
-
|
57 |
-
|
58 |
/* Hover effect */
|
59 |
.remove-btn:hover {
|
60 |
color: black; /* Change the icon color to black on hover */
|
@@ -65,8 +79,9 @@
|
|
65 |
outline: none; /* Remove the outline */
|
66 |
background-color: transparent; /* Keep background transparent after clicking */
|
67 |
}
|
|
|
68 |
.text-primary {
|
69 |
-
color: #
|
70 |
text-align: right; /* Center-align the price */
|
71 |
font-weight: bold; /* Make the price text bold */
|
72 |
white-space: nowrap; /* Prevent price text from wrapping */
|
@@ -79,7 +94,6 @@
|
|
79 |
align-items: center; /* Center image vertically */
|
80 |
justify-content: center; /* Center image horizontally */
|
81 |
}
|
82 |
-
|
83 |
/* For the image */
|
84 |
.cart-item img {
|
85 |
width: 70px; /* Set the width to 70px */
|
@@ -89,7 +103,6 @@
|
|
89 |
border: 1px solid #ffcc80; /* Light orange border around images */
|
90 |
margin: 0; /* Ensure no extra space around the image */
|
91 |
}
|
92 |
-
|
93 |
|
94 |
.cart-item img:hover {
|
95 |
transform: scale(1.05);
|
@@ -100,19 +113,19 @@
|
|
100 |
}
|
101 |
|
102 |
.checkout-button {
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
}
|
117 |
.add-back-button {
|
118 |
padding: 6px 20px;
|
@@ -164,7 +177,16 @@
|
|
164 |
padding: 20px;
|
165 |
background-color: #fff;
|
166 |
border-radius: 12px;
|
|
|
167 |
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
/* Coupon Section styling */
|
170 |
.coupon-selection {
|
@@ -257,15 +279,15 @@
|
|
257 |
.total-bill .amount {
|
258 |
text-align: right;
|
259 |
font-size: 1.1rem;
|
260 |
-
color: #
|
261 |
}
|
262 |
/* Margin to add space for dropdown when visible */
|
263 |
.cart-summary.has-dropdown {
|
264 |
margin-bottom: 80px; /* Create space below the content when dropdown is visible */
|
265 |
}
|
266 |
.checkout-button {
|
267 |
-
background-color:
|
268 |
-
color:
|
269 |
padding: 12px;
|
270 |
border-radius: 8px;
|
271 |
border: none;
|
@@ -284,6 +306,7 @@
|
|
284 |
padding: 15px;
|
285 |
background-color: #fff;
|
286 |
border-radius: 10px;
|
|
|
287 |
}
|
288 |
.suggestion-items-container {
|
289 |
display: flex;
|
@@ -308,6 +331,7 @@
|
|
308 |
position: relative; /* For positioning the + icon */
|
309 |
text-align: left; /* Align text to the left */
|
310 |
overflow: visible; /* Allow the button to overflow outside */
|
|
|
311 |
}
|
312 |
.suggestion-item:hover {
|
313 |
transform: scale(1.05); /* Slight zoom effect on hover */
|
@@ -363,7 +387,15 @@
|
|
363 |
align-items: flex-start; /* Align the price at the top of the cart item (like the item name) */
|
364 |
margin-left: auto; /* This will push the price to the right side of the cart item */
|
365 |
}
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
</style>
|
368 |
</head>
|
369 |
<body>
|
@@ -496,13 +528,11 @@
|
|
496 |
} else if (action === 'decrease' && quantity > 1) {
|
497 |
quantity--;
|
498 |
}
|
499 |
-
|
500 |
// Validate quantity
|
501 |
if (isNaN(quantity) || quantity < 1) {
|
502 |
alert("Invalid quantity!");
|
503 |
return;
|
504 |
}
|
505 |
-
|
506 |
// Send updated quantity to the server
|
507 |
fetch('/cart/update_quantity', {
|
508 |
method: 'POST',
|
@@ -518,12 +548,10 @@
|
|
518 |
if (itemElement) {
|
519 |
let basePriceElement = itemElement.querySelector(".base-price");
|
520 |
let addonsPriceElement = itemElement.querySelector(".addons-price");
|
521 |
-
|
522 |
// Update the base price
|
523 |
if (basePriceElement) {
|
524 |
basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
|
525 |
}
|
526 |
-
|
527 |
// Update add-ons price if needed (optional)
|
528 |
if (addonsPriceElement && data.addons_price !== undefined) {
|
529 |
addonsPriceElement.innerText = data.addons_price.toFixed(2);
|
@@ -532,7 +560,6 @@
|
|
532 |
console.error(`Parent cart item element not found for item: ${itemName}`);
|
533 |
}
|
534 |
location.reload();
|
535 |
-
|
536 |
// Recalculate subtotal dynamically
|
537 |
|
538 |
} else {
|
@@ -551,19 +578,15 @@
|
|
551 |
couponDropdown.style.display = "none";
|
552 |
}
|
553 |
}
|
554 |
-
|
555 |
-
|
556 |
function calculateDiscount() {
|
557 |
let couponDropdown = document.getElementById('couponDropdown'); // Get coupon dropdown
|
558 |
let selectedCoupon = couponDropdown.value.trim(); // Get the selected coupon value
|
559 |
let subtotal = parseFloat("{{ subtotal }}"); // Get the subtotal (from the backend)
|
560 |
-
|
561 |
// If a valid coupon is selected
|
562 |
if (selectedCoupon && selectedCoupon.toLowerCase() !== "none") {
|
563 |
// Apply 10% discount
|
564 |
let discount = subtotal * 0.10;
|
565 |
let total = subtotal - discount;
|
566 |
-
|
567 |
// Update UI with discount and total bill
|
568 |
document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
|
569 |
document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
|
@@ -573,9 +596,6 @@
|
|
573 |
document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
|
574 |
}
|
575 |
}
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
|
580 |
function proceedToOrder() {
|
581 |
let couponDropdown = document.getElementById('couponDropdown');
|
@@ -592,12 +612,10 @@
|
|
592 |
selectedCoupon = ""; // Assign empty string if value is null
|
593 |
}
|
594 |
}
|
595 |
-
|
596 |
// If no coupon is selected or the value is empty, treat it as no coupon
|
597 |
if (selectedCoupon === "" || selectedCoupon === "None" || selectedCoupon === "Null") {
|
598 |
selectedCoupon = null; // Treat it as no coupon selected
|
599 |
}
|
600 |
-
|
601 |
// Send the selected coupon to the backend for processing
|
602 |
fetch('/checkout', {
|
603 |
method: 'POST',
|
@@ -615,9 +633,6 @@
|
|
615 |
})
|
616 |
.catch(err => console.error('Error during checkout:', err));
|
617 |
}
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
function calculateSubtotal() {
|
622 |
let subtotal = 0;
|
623 |
document.querySelectorAll('.cart-item').forEach(item => {
|
@@ -626,7 +641,6 @@
|
|
626 |
const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
|
627 |
subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
|
628 |
});
|
629 |
-
|
630 |
// Update the subtotal in the HTML
|
631 |
document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
|
632 |
return subtotal;
|
@@ -735,11 +749,9 @@
|
|
735 |
})
|
736 |
.catch(err => console.error('Error adding item:', err));
|
737 |
}
|
738 |
-
|
739 |
-
|
740 |
|
741 |
|
742 |
</script>
|
743 |
|
744 |
</body>
|
745 |
-
</html>
|
|
|
10 |
|
11 |
body {
|
12 |
font-family: Arial, sans-serif;
|
13 |
+
background-color: #fdf4e3; /* Updated background color */
|
14 |
color: #333;
|
15 |
}
|
16 |
.cart-container {
|
17 |
max-width: 768px;
|
18 |
margin: 20px auto;
|
19 |
padding: 15px;
|
20 |
+
background-color: #FFFFFF;
|
21 |
border-radius: 10px;
|
22 |
+
|
23 |
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
24 |
}
|
25 |
.cart-container2 {
|
26 |
+
background-color:#FFFFFF;
|
27 |
}
|
28 |
+
/* Green Back Button styling */
|
29 |
+
.back-button {
|
30 |
+
position: absolute;
|
31 |
+
top: 15px;
|
32 |
+
left: 15px;
|
33 |
+
display: inline-block;
|
34 |
+
background-color: green; /* Green color */
|
35 |
+
color: white;
|
36 |
+
padding: 10px 20px;
|
37 |
+
text-decoration: none;
|
38 |
+
font-weight: bold;
|
39 |
+
border-radius: 4px;
|
40 |
+
z-index: 10; /* Ensure it stays above other content */
|
41 |
+
}
|
42 |
+
.back-button:hover {
|
43 |
+
background-color: darkgreen; /* Darker green color on hover */
|
44 |
+
}
|
45 |
+
.cart-item {
|
46 |
display: flex;
|
47 |
align-items: flex-start;
|
48 |
justify-content: space-between;
|
|
|
52 |
box-sizing: border-box;
|
53 |
min-height: 100px;
|
54 |
position: relative; /* Make the cart item a reference for the absolute positioning of the remove icon */
|
55 |
+
border: 1px solid #fdf4e3; /* light Orange border around each item */
|
56 |
+
border-radius: 8px; /* Rounded corners for items */
|
57 |
}
|
|
|
58 |
.remove-btn {
|
59 |
border: none; /* Remove the border around the button */
|
60 |
background-color: transparent; /* Transparent background */
|
|
|
66 |
top: -35px; /* Move the button 10px upwards */
|
67 |
left: 50px; /* Move the button 30px to the right */
|
68 |
}
|
|
|
69 |
.remove-btn i {
|
70 |
color: red; /* Make the trash icon red */
|
71 |
}
|
|
|
|
|
72 |
/* Hover effect */
|
73 |
.remove-btn:hover {
|
74 |
color: black; /* Change the icon color to black on hover */
|
|
|
79 |
outline: none; /* Remove the outline */
|
80 |
background-color: transparent; /* Keep background transparent after clicking */
|
81 |
}
|
82 |
+
/* Green Color for Prices */
|
83 |
.text-primary {
|
84 |
+
color: #2e7d32; /* Green color for the prices */
|
85 |
text-align: right; /* Center-align the price */
|
86 |
font-weight: bold; /* Make the price text bold */
|
87 |
white-space: nowrap; /* Prevent price text from wrapping */
|
|
|
94 |
align-items: center; /* Center image vertically */
|
95 |
justify-content: center; /* Center image horizontally */
|
96 |
}
|
|
|
97 |
/* For the image */
|
98 |
.cart-item img {
|
99 |
width: 70px; /* Set the width to 70px */
|
|
|
103 |
border: 1px solid #ffcc80; /* Light orange border around images */
|
104 |
margin: 0; /* Ensure no extra space around the image */
|
105 |
}
|
|
|
106 |
|
107 |
.cart-item img:hover {
|
108 |
transform: scale(1.05);
|
|
|
113 |
}
|
114 |
|
115 |
.checkout-button {
|
116 |
+
background-color: #ff5722; /* Full Orange color */
|
117 |
+
color: #ffffff; /* White text */
|
118 |
+
padding: 12px;
|
119 |
+
border-radius: 8px;
|
120 |
+
border: none;
|
121 |
+
width: 100%;
|
122 |
+
font-size: 1.2rem;
|
123 |
+
cursor: pointer;
|
124 |
+
transition: background-color 0.3s, color 0.3s;
|
125 |
+
}
|
126 |
+
.checkout-button:hover {
|
127 |
+
background-color: #ff5722; /* Full Orange color on hover */
|
128 |
+
color: #ffffff; /* White text on hover */
|
129 |
}
|
130 |
.add-back-button {
|
131 |
padding: 6px 20px;
|
|
|
177 |
padding: 20px;
|
178 |
background-color: #fff;
|
179 |
border-radius: 12px;
|
180 |
+
border: 2px solid #fdf4e3; /* light Orange border around the cart summary */
|
181 |
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
|
182 |
+
}
|
183 |
+
.cart-item-instructions {
|
184 |
+
word-wrap: break-word; /* Ensure that long instructions text wraps to the next line */
|
185 |
+
white-space: normal; /* Allow text to wrap and prevent overflow */
|
186 |
+
overflow: hidden; /* Hide any overflow text */
|
187 |
+
max-width: 100%; /* Ensure instructions text stays within the container's width */
|
188 |
+
word-break: break-word; /* Break the word when necessary */
|
189 |
+
|
190 |
}
|
191 |
/* Coupon Section styling */
|
192 |
.coupon-selection {
|
|
|
279 |
.total-bill .amount {
|
280 |
text-align: right;
|
281 |
font-size: 1.1rem;
|
282 |
+
color: #2e7d32; /* Green for Total Bill Price */
|
283 |
}
|
284 |
/* Margin to add space for dropdown when visible */
|
285 |
.cart-summary.has-dropdown {
|
286 |
margin-bottom: 80px; /* Create space below the content when dropdown is visible */
|
287 |
}
|
288 |
.checkout-button {
|
289 |
+
background-color: #ff5722;
|
290 |
+
color: #ffffff;
|
291 |
padding: 12px;
|
292 |
border-radius: 8px;
|
293 |
border: none;
|
|
|
306 |
padding: 15px;
|
307 |
background-color: #fff;
|
308 |
border-radius: 10px;
|
309 |
+
border: 2px solid #fdf4e3; /* light Orange border around the complete meal box */
|
310 |
}
|
311 |
.suggestion-items-container {
|
312 |
display: flex;
|
|
|
331 |
position: relative; /* For positioning the + icon */
|
332 |
text-align: left; /* Align text to the left */
|
333 |
overflow: visible; /* Allow the button to overflow outside */
|
334 |
+
border: 2px solid #fdf4e3; /* light Orange border around the suggestion items */
|
335 |
}
|
336 |
.suggestion-item:hover {
|
337 |
transform: scale(1.05); /* Slight zoom effect on hover */
|
|
|
387 |
align-items: flex-start; /* Align the price at the top of the cart item (like the item name) */
|
388 |
margin-left: auto; /* This will push the price to the right side of the cart item */
|
389 |
}
|
390 |
+
h4.mb-4.fw-bold {
|
391 |
+
text-align: center; /* Centers the title */
|
392 |
+
color: #FF5722; /* Orange color for the title */
|
393 |
+
.cart-container h4 {
|
394 |
+
text-align: center; /* This will center the title horizontally */
|
395 |
+
color: #FF5722; /* Orange color */
|
396 |
+
font-weight: bold; /* Make it bold */
|
397 |
+
}
|
398 |
+
|
399 |
</style>
|
400 |
</head>
|
401 |
<body>
|
|
|
528 |
} else if (action === 'decrease' && quantity > 1) {
|
529 |
quantity--;
|
530 |
}
|
|
|
531 |
// Validate quantity
|
532 |
if (isNaN(quantity) || quantity < 1) {
|
533 |
alert("Invalid quantity!");
|
534 |
return;
|
535 |
}
|
|
|
536 |
// Send updated quantity to the server
|
537 |
fetch('/cart/update_quantity', {
|
538 |
method: 'POST',
|
|
|
548 |
if (itemElement) {
|
549 |
let basePriceElement = itemElement.querySelector(".base-price");
|
550 |
let addonsPriceElement = itemElement.querySelector(".addons-price");
|
|
|
551 |
// Update the base price
|
552 |
if (basePriceElement) {
|
553 |
basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
|
554 |
}
|
|
|
555 |
// Update add-ons price if needed (optional)
|
556 |
if (addonsPriceElement && data.addons_price !== undefined) {
|
557 |
addonsPriceElement.innerText = data.addons_price.toFixed(2);
|
|
|
560 |
console.error(`Parent cart item element not found for item: ${itemName}`);
|
561 |
}
|
562 |
location.reload();
|
|
|
563 |
// Recalculate subtotal dynamically
|
564 |
|
565 |
} else {
|
|
|
578 |
couponDropdown.style.display = "none";
|
579 |
}
|
580 |
}
|
|
|
|
|
581 |
function calculateDiscount() {
|
582 |
let couponDropdown = document.getElementById('couponDropdown'); // Get coupon dropdown
|
583 |
let selectedCoupon = couponDropdown.value.trim(); // Get the selected coupon value
|
584 |
let subtotal = parseFloat("{{ subtotal }}"); // Get the subtotal (from the backend)
|
|
|
585 |
// If a valid coupon is selected
|
586 |
if (selectedCoupon && selectedCoupon.toLowerCase() !== "none") {
|
587 |
// Apply 10% discount
|
588 |
let discount = subtotal * 0.10;
|
589 |
let total = subtotal - discount;
|
|
|
590 |
// Update UI with discount and total bill
|
591 |
document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
|
592 |
document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
|
|
|
596 |
document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
|
597 |
}
|
598 |
}
|
|
|
|
|
|
|
599 |
|
600 |
function proceedToOrder() {
|
601 |
let couponDropdown = document.getElementById('couponDropdown');
|
|
|
612 |
selectedCoupon = ""; // Assign empty string if value is null
|
613 |
}
|
614 |
}
|
|
|
615 |
// If no coupon is selected or the value is empty, treat it as no coupon
|
616 |
if (selectedCoupon === "" || selectedCoupon === "None" || selectedCoupon === "Null") {
|
617 |
selectedCoupon = null; // Treat it as no coupon selected
|
618 |
}
|
|
|
619 |
// Send the selected coupon to the backend for processing
|
620 |
fetch('/checkout', {
|
621 |
method: 'POST',
|
|
|
633 |
})
|
634 |
.catch(err => console.error('Error during checkout:', err));
|
635 |
}
|
|
|
|
|
|
|
636 |
function calculateSubtotal() {
|
637 |
let subtotal = 0;
|
638 |
document.querySelectorAll('.cart-item').forEach(item => {
|
|
|
641 |
const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
|
642 |
subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
|
643 |
});
|
|
|
644 |
// Update the subtotal in the HTML
|
645 |
document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
|
646 |
return subtotal;
|
|
|
749 |
})
|
750 |
.catch(err => console.error('Error adding item:', err));
|
751 |
}
|
|
|
|
|
752 |
|
753 |
|
754 |
</script>
|
755 |
|
756 |
</body>
|
757 |
+
</html>
|