Update templates/cart.html
Browse files- templates/cart.html +408 -422
templates/cart.html
CHANGED
@@ -6,358 +6,339 @@
|
|
6 |
<title>Cart</title>
|
7 |
<!-- Bootstrap CSS -->
|
8 |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
|
9 |
<style>
|
10 |
-
|
11 |
font-family: Arial, sans-serif;
|
12 |
background-color: #fdf4e3;
|
13 |
color: #333;
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
ar-thumb {
|
341 |
-
background-color: #fff;
|
342 |
-
border-radius: 4px;
|
343 |
-
}
|
344 |
-
.suggestion-items-container::-webkit-scrollbar-track {
|
345 |
-
background-color: #f1f1f1;
|
346 |
-
}
|
347 |
-
.cart-item-actions {
|
348 |
-
display: flex;
|
349 |
-
align-items: flex-start;
|
350 |
-
margin-left: auto;
|
351 |
-
}
|
352 |
-
h4.mb-4.fw-bold {
|
353 |
-
text-align: center;
|
354 |
-
color: #FF5722;
|
355 |
-
}
|
356 |
-
.cart-container h4 {
|
357 |
-
text-align: center;
|
358 |
-
color: #FF5722;
|
359 |
-
font-weight: bold;
|
360 |
-
}
|
361 |
</style>
|
362 |
</head>
|
363 |
<body>
|
@@ -368,84 +349,87 @@ ar-thumb {
|
|
368 |
<span class="back-label">Back to Menu</span>
|
369 |
</a>
|
370 |
</div>
|
371 |
-
|
372 |
-
|
|
|
|
|
373 |
<div class="container">
|
374 |
<div class="cart-container">
|
375 |
-
<div style="text-align: right;"></div>
|
376 |
<div class="cart-container2">
|
377 |
{% for item in cart_items %}
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
</div>
|
382 |
-
<div class="cart-item-details">
|
383 |
-
<div class="cart-item-title">{{ item.Name }}</div>
|
384 |
-
<div class="cart-item-addons">
|
385 |
-
<small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
|
386 |
</div>
|
387 |
-
<div class="cart-item-
|
388 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
</div>
|
390 |
-
<div class="cart-item-
|
391 |
-
<button onclick="
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
</div>
|
396 |
-
<div class="cart-item-actions">
|
397 |
-
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
|
398 |
-
<button type="button" class="btn btn-light text-dark remove-btn" onclick="removeItemFromCart('{{ item.Name }}')">
|
399 |
-
<i class="bi bi-trash"></i>
|
400 |
-
</button>
|
401 |
-
<div class="text-primary" style="color: #000 !important;">
|
402 |
-
$<span class="base-price">{{ item.Price__c }}</span>
|
403 |
</div>
|
404 |
</div>
|
405 |
-
</div>
|
406 |
{% else %}
|
407 |
-
|
408 |
{% endfor %}
|
409 |
</div>
|
|
|
410 |
<!-- Suggestions Section -->
|
411 |
{% if suggestions %}
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
|
|
|
|
423 |
</div>
|
424 |
-
{% endfor %}
|
425 |
</div>
|
426 |
-
</div>
|
427 |
{% endif %}
|
|
|
428 |
<!-- Subtotal -->
|
429 |
<div class="cart-summary">
|
430 |
{% if coupons %}
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
{% endif %}
|
|
|
442 |
<div class="bill-details">
|
443 |
<div class="label">Cart Total</div>
|
444 |
<div class="amount">${{ subtotal }}</div>
|
445 |
<div class="label">Discount</div>
|
446 |
<div class="amount" id="discountText">-${{ discount }}</div>
|
447 |
</div>
|
|
|
448 |
<div class="dotted-line"></div>
|
|
|
449 |
<div class="total-bill">
|
450 |
<div class="label">To Pay</div>
|
451 |
<div class="amount" id="totalBillText">${{ subtotal }}</div>
|
@@ -454,8 +438,8 @@ ar-thumb {
|
|
454 |
</div>
|
455 |
</div>
|
456 |
</div>
|
|
|
457 |
<script>
|
458 |
-
// Update quantity
|
459 |
function updateQuantity(action, itemName, customerEmail) {
|
460 |
let quantityInput = document.querySelector(`input[data-item-name="${itemName}"]`);
|
461 |
let quantity = parseInt(quantityInput.value);
|
@@ -479,9 +463,9 @@ ar-thumb {
|
|
479 |
quantityInput.value = quantity;
|
480 |
let itemElement = quantityInput.closest(".cart-item");
|
481 |
if (itemElement) {
|
482 |
-
let basePriceElement = itemElement.querySelector(".
|
483 |
-
if (basePriceElement) {
|
484 |
-
basePriceElement.innerText = data.new_item_price.toFixed(2)
|
485 |
}
|
486 |
}
|
487 |
location.reload();
|
@@ -491,12 +475,16 @@ ar-thumb {
|
|
491 |
})
|
492 |
.catch(err => console.error("Error:", err));
|
493 |
}
|
494 |
-
|
495 |
function toggleCouponDropdown() {
|
496 |
let couponDropdown = document.getElementById('couponDropdown');
|
497 |
-
|
|
|
|
|
|
|
|
|
498 |
}
|
499 |
-
|
500 |
function calculateDiscount() {
|
501 |
let couponDropdown = document.getElementById('couponDropdown');
|
502 |
let selectedCoupon = couponDropdown.value.trim();
|
@@ -511,38 +499,36 @@ ar-thumb {
|
|
511 |
document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
|
512 |
}
|
513 |
}
|
514 |
-
|
515 |
function proceedToOrder() {
|
516 |
let couponDropdown = document.getElementById('couponDropdown');
|
517 |
-
let selectedCoupon =
|
518 |
-
if (
|
|
|
|
|
|
|
519 |
selectedCoupon = null;
|
520 |
}
|
521 |
-
fetch('/checkout', {
|
522 |
method: 'POST',
|
523 |
headers: { 'Content-Type': 'application/json' },
|
524 |
body: JSON.stringify({ selectedCoupon: selectedCoupon })
|
525 |
})
|
526 |
-
.then(response =>
|
527 |
-
if (!response.ok) {
|
528 |
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
529 |
-
}
|
530 |
-
return response.json();
|
531 |
-
})
|
532 |
.then(data => {
|
533 |
if (data.success) {
|
534 |
-
alert(data.message
|
535 |
window.location.href = '/order';
|
536 |
} else {
|
537 |
-
alert(data.error ||
|
538 |
}
|
539 |
})
|
540 |
.catch(err => {
|
541 |
console.error('Error during checkout:', err);
|
542 |
-
alert(
|
543 |
});
|
544 |
}
|
545 |
-
|
546 |
function removeItemFromCart(itemName) {
|
547 |
fetch(`/cart/remove/${encodeURIComponent(itemName)}`, {
|
548 |
method: 'POST',
|
@@ -559,7 +545,7 @@ ar-thumb {
|
|
559 |
})
|
560 |
.catch(err => console.error('Error removing item:', err));
|
561 |
}
|
562 |
-
|
563 |
function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
|
564 |
const customerEmail = "{{ customer_email }}";
|
565 |
const data = {
|
@@ -582,7 +568,7 @@ ar-thumb {
|
|
582 |
alert('Item added to cart!');
|
583 |
location.reload();
|
584 |
} else {
|
585 |
-
|
586 |
}
|
587 |
})
|
588 |
.catch(err => console.error('Error adding item:', err));
|
|
|
6 |
<title>Cart</title>
|
7 |
<!-- Bootstrap CSS -->
|
8 |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
|
9 |
+
<!-- Bootstrap Icons -->
|
10 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
|
11 |
<style>
|
12 |
+
body {
|
13 |
font-family: Arial, sans-serif;
|
14 |
background-color: #fdf4e3;
|
15 |
color: #333;
|
16 |
+
}
|
17 |
+
|
18 |
+
/* Top orange bar */
|
19 |
+
.top-bar {
|
20 |
+
background-color: #FF6F3C;
|
21 |
+
width: 100%;
|
22 |
+
padding: 10px 15px;
|
23 |
+
display: flex;
|
24 |
+
align-items: center;
|
25 |
+
box-sizing: border-box;
|
26 |
+
}
|
27 |
+
.back-link {
|
28 |
+
display: flex;
|
29 |
+
align-items: center;
|
30 |
+
text-decoration: none;
|
31 |
+
}
|
32 |
+
.back-arrow {
|
33 |
+
font-size: 1.8rem;
|
34 |
+
color: #000;
|
35 |
+
font-weight: bold;
|
36 |
+
}
|
37 |
+
.back-label {
|
38 |
+
margin-left: 10px;
|
39 |
+
color: white;
|
40 |
+
font-weight: bold;
|
41 |
+
font-size: 1rem;
|
42 |
+
}
|
43 |
+
|
44 |
+
/* Title Styling */
|
45 |
+
.order-heading {
|
46 |
+
color: #000;
|
47 |
+
font-size: 2.5rem;
|
48 |
+
font-weight: bold;
|
49 |
+
text-align: center;
|
50 |
+
margin-top: 30px;
|
51 |
+
}
|
52 |
+
|
53 |
+
.cart-container {
|
54 |
+
max-width: 768px;
|
55 |
+
margin: 20px auto;
|
56 |
+
padding: 15px;
|
57 |
+
background-color: #FFFFFF;
|
58 |
+
border-radius: 10px;
|
59 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
60 |
+
}
|
61 |
+
.cart-container2 {
|
62 |
+
background-color: #FFFFFF;
|
63 |
+
display: flex;
|
64 |
+
flex-direction: column;
|
65 |
+
padding: 10px;
|
66 |
+
}
|
67 |
+
.cart-item {
|
68 |
+
display: flex;
|
69 |
+
align-items: flex-start;
|
70 |
+
justify-content: space-between;
|
71 |
+
border: 1px solid #fdf4e3;
|
72 |
+
padding: 30px 15px 15px;
|
73 |
+
background-color: #fff;
|
74 |
+
box-sizing: border-box;
|
75 |
+
min-height: 100px;
|
76 |
+
position: relative;
|
77 |
+
border-radius: 8px;
|
78 |
+
}
|
79 |
+
.remove-btn {
|
80 |
+
border: none;
|
81 |
+
background-color: transparent;
|
82 |
+
cursor: pointer;
|
83 |
+
font-size: 1.2rem;
|
84 |
+
margin-bottom: 10px;
|
85 |
+
transition: color 0.3s ease;
|
86 |
+
position: relative;
|
87 |
+
top: -35px;
|
88 |
+
left: 50px;
|
89 |
+
}
|
90 |
+
.remove-btn i {
|
91 |
+
color: red;
|
92 |
+
}
|
93 |
+
.remove-btn:hover {
|
94 |
+
color: black;
|
95 |
+
background-color: transparent;
|
96 |
+
}
|
97 |
+
.remove-btn:focus {
|
98 |
+
outline: none;
|
99 |
+
background-color: transparent;
|
100 |
+
}
|
101 |
+
.text-primary {
|
102 |
+
color: #2e7d32;
|
103 |
+
text-align: right;
|
104 |
+
font-weight: bold;
|
105 |
+
white-space: nowrap;
|
106 |
+
}
|
107 |
+
.image-wrapper {
|
108 |
+
width: 80px;
|
109 |
+
height: 80px !important;
|
110 |
+
display: flex;
|
111 |
+
align-items: center;
|
112 |
+
justify-content: center;
|
113 |
+
}
|
114 |
+
.cart-item img {
|
115 |
+
width: 70px;
|
116 |
+
height: 70px;
|
117 |
+
object-fit: cover;
|
118 |
+
border-radius: 5px;
|
119 |
+
border: 1px solid #ffcc80;
|
120 |
+
margin: 0;
|
121 |
+
}
|
122 |
+
.cart-item img:hover {
|
123 |
+
transform: scale(1.05);
|
124 |
+
}
|
125 |
+
.cart-item-title {
|
126 |
+
font-size: 1.1rem;
|
127 |
+
font-weight: bold;
|
128 |
+
}
|
129 |
+
.checkout-button {
|
130 |
+
background-color: #A52A2A;
|
131 |
+
color: #ffffff;
|
132 |
+
padding: 12px;
|
133 |
+
border-radius: 8px;
|
134 |
+
border: none;
|
135 |
+
width: 100%;
|
136 |
+
font-size: 1rem;
|
137 |
+
cursor: pointer;
|
138 |
+
transition: background-color 0.3s, color 0.3s;
|
139 |
+
display: flex;
|
140 |
+
justify-content: center;
|
141 |
+
align-items: center;
|
142 |
+
text-align: center;
|
143 |
+
}
|
144 |
+
.checkout-button:hover {
|
145 |
+
background-color: #A52A2A;
|
146 |
+
color: #ffffff;
|
147 |
+
}
|
148 |
+
.add-back-button {
|
149 |
+
position: absolute;
|
150 |
+
top: -5px;
|
151 |
+
right: -10px;
|
152 |
+
font-size: 1rem;
|
153 |
+
padding: 0;
|
154 |
+
width: 30px;
|
155 |
+
height: 30px;
|
156 |
+
background-color: #fff;
|
157 |
+
color: #0FAA39;
|
158 |
+
border: 2px solid #0FAA39;
|
159 |
+
border-radius: 0;
|
160 |
+
cursor: pointer;
|
161 |
+
transition: background-color 0.3s, color 0.3s, border-color 0.3s;
|
162 |
+
z-index: 2;
|
163 |
+
}
|
164 |
+
.add-back-button:hover {
|
165 |
+
background-color: #fff;
|
166 |
+
color: #0FAA39;
|
167 |
+
border-color: #0FAA39;
|
168 |
+
z-index: 3;
|
169 |
+
}
|
170 |
+
.cart-item-details {
|
171 |
+
flex: 1;
|
172 |
+
margin-left: 15px;
|
173 |
+
}
|
174 |
+
.cart-item-quantity {
|
175 |
+
display: flex;
|
176 |
+
align-items: center;
|
177 |
+
margin-top: 5px;
|
178 |
+
}
|
179 |
+
.cart-item-quantity button {
|
180 |
+
width: 24px;
|
181 |
+
height: 24px;
|
182 |
+
border: none;
|
183 |
+
background-color: #f0f0f0;
|
184 |
+
font-size: 0.8rem;
|
185 |
+
font-weight: bold;
|
186 |
+
cursor: pointer;
|
187 |
+
}
|
188 |
+
.cart-item-quantity input {
|
189 |
+
width: 40px;
|
190 |
+
text-align: center;
|
191 |
+
border: none;
|
192 |
+
background-color: #f8f9fa;
|
193 |
+
font-size: 1rem;
|
194 |
+
margin: 0 5px;
|
195 |
+
}
|
196 |
+
.cart-summary {
|
197 |
+
position: relative;
|
198 |
+
text-align: left;
|
199 |
+
margin-top: 15px;
|
200 |
+
padding: 20px;
|
201 |
+
background-color: #fff;
|
202 |
+
border-radius: 12px;
|
203 |
+
border: 2px solid #fdf4e3;
|
204 |
+
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
|
205 |
+
}
|
206 |
+
.cart-item-instructions {
|
207 |
+
word-wrap: break-word;
|
208 |
+
white-space: normal;
|
209 |
+
overflow: hidden;
|
210 |
+
max-width: 100%;
|
211 |
+
word-break: break-word;
|
212 |
+
}
|
213 |
+
.coupon-selection {
|
214 |
+
display: flex;
|
215 |
+
justify-content: space-between;
|
216 |
+
align-items: center;
|
217 |
+
font-size: 1rem;
|
218 |
+
margin-bottom: 20px;
|
219 |
+
position: relative;
|
220 |
+
}
|
221 |
+
.coupon-selection label {
|
222 |
+
font-weight: bold;
|
223 |
+
color: black;
|
224 |
+
}
|
225 |
+
.coupon-selection a {
|
226 |
+
color: #007bff;
|
227 |
+
font-size: 1rem;
|
228 |
+
text-decoration: none;
|
229 |
+
text-align: right;
|
230 |
+
}
|
231 |
+
#couponDropdown {
|
232 |
+
width: 30%;
|
233 |
+
display: none;
|
234 |
+
background-color: #fff;
|
235 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
236 |
+
z-index: 10;
|
237 |
+
margin-top: 10px;
|
238 |
+
margin-left: auto;
|
239 |
+
margin-right: 0;
|
240 |
+
}
|
241 |
+
#couponDropdown.show {
|
242 |
+
display: block;
|
243 |
+
}
|
244 |
+
.bill-details {
|
245 |
+
display: grid;
|
246 |
+
grid-template-columns: 1fr 1fr;
|
247 |
+
grid-gap: 10px;
|
248 |
+
margin-bottom: 10px;
|
249 |
+
}
|
250 |
+
.bill-details .label {
|
251 |
+
font-weight: 600;
|
252 |
+
font-size: 1rem;
|
253 |
+
}
|
254 |
+
.bill-details .amount {
|
255 |
+
text-align: right;
|
256 |
+
font-weight: 600;
|
257 |
+
font-size: 1rem;
|
258 |
+
}
|
259 |
+
.dotted-line {
|
260 |
+
border-bottom: 2px dotted #ccc;
|
261 |
+
margin: 15px 0;
|
262 |
+
}
|
263 |
+
.total-bill {
|
264 |
+
display: grid;
|
265 |
+
grid-template-columns: 1fr 1fr;
|
266 |
+
font-weight: 600;
|
267 |
+
font-size: 1.2rem;
|
268 |
+
margin-top: 10px;
|
269 |
+
margin-bottom: 10px;
|
270 |
+
}
|
271 |
+
.total-bill .label {
|
272 |
+
font-size: 1.1rem;
|
273 |
+
}
|
274 |
+
.total-bill .amount {
|
275 |
+
text-align: right;
|
276 |
+
font-size: 1.1rem;
|
277 |
+
color: #2e7d32;
|
278 |
+
}
|
279 |
+
.cart-summary.has-dropdown {
|
280 |
+
margin-bottom: 80px;
|
281 |
+
}
|
282 |
+
.suggestion-section {
|
283 |
+
margin-top: 25px;
|
284 |
+
padding: 15px;
|
285 |
+
background-color: #fff;
|
286 |
+
border-radius: 10px;
|
287 |
+
border: 2px solid #fdf4e3;
|
288 |
+
}
|
289 |
+
.suggestion-items-container {
|
290 |
+
display: flex;
|
291 |
+
overflow-x: auto;
|
292 |
+
gap: 10px;
|
293 |
+
padding-bottom: 10px;
|
294 |
+
padding-top: 10px;
|
295 |
+
}
|
296 |
+
.suggestion-item {
|
297 |
+
display: flex;
|
298 |
+
align-items: center;
|
299 |
+
justify-content: flex-start;
|
300 |
+
flex-shrink: 0;
|
301 |
+
width: 160px;
|
302 |
+
padding: 10px;
|
303 |
+
border-radius: 8px;
|
304 |
+
background-color: #fff;
|
305 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
306 |
+
transition: transform 0.3s ease;
|
307 |
+
margin-right: 10px;
|
308 |
+
position: relative;
|
309 |
+
text-align: left;
|
310 |
+
overflow: visible;
|
311 |
+
border: 2px solid #fdf4e3;
|
312 |
+
}
|
313 |
+
.suggestion-item:hover {
|
314 |
+
transform: scale(1.05);
|
315 |
+
}
|
316 |
+
.suggestion-item img {
|
317 |
+
width: 50px;
|
318 |
+
height: 50px;
|
319 |
+
object-fit: cover;
|
320 |
+
border-radius: 5px;
|
321 |
+
margin-right: 12px;
|
322 |
+
}
|
323 |
+
.suggestion-item div {
|
324 |
+
flex-grow: 1;
|
325 |
+
text-align: left;
|
326 |
+
}
|
327 |
+
.suggestion-items-container::-webkit-scrollbar {
|
328 |
+
height: 8px;
|
329 |
+
}
|
330 |
+
.suggestion-items-container::-webkit-scrollbar-thumb {
|
331 |
+
background-color: #fff;
|
332 |
+
border-radius: 4px;
|
333 |
+
}
|
334 |
+
.suggestion-items-container::-webkit-scrollbar-track {
|
335 |
+
background-color: #f1f1f1;
|
336 |
+
}
|
337 |
+
.cart-item-actions {
|
338 |
+
display: flex;
|
339 |
+
align-items: flex-start;
|
340 |
+
margin-left: auto;
|
341 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
</style>
|
343 |
</head>
|
344 |
<body>
|
|
|
349 |
<span class="back-label">Back to Menu</span>
|
350 |
</a>
|
351 |
</div>
|
352 |
+
|
353 |
+
<!-- Order History Title -->
|
354 |
+
<div class="order-heading">Your Cart</div>
|
355 |
+
|
356 |
<div class="container">
|
357 |
<div class="cart-container">
|
|
|
358 |
<div class="cart-container2">
|
359 |
{% for item in cart_items %}
|
360 |
+
<div class="cart-item">
|
361 |
+
<div class="image-wrapper">
|
362 |
+
<img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
|
|
|
|
|
|
|
|
|
|
|
363 |
</div>
|
364 |
+
<div class="cart-item-details">
|
365 |
+
<div class="cart-item-title">{{ item.Name }}</div>
|
366 |
+
<div class="cart-item-addons">
|
367 |
+
<small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
|
368 |
+
</div>
|
369 |
+
<div class="cart-item-instructions">
|
370 |
+
<small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
|
371 |
+
</div>
|
372 |
+
<div class="cart-item-quantity mt-2">
|
373 |
+
<button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
|
374 |
+
<input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
|
375 |
+
<button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
|
376 |
+
</div>
|
377 |
</div>
|
378 |
+
<div class="cart-item-actions">
|
379 |
+
<button type="button" class="btn btn-light text-dark remove-btn" onclick="removeItemFromCart('{{ item.Name }}')">
|
380 |
+
<i class="bi bi-trash"></i>
|
381 |
+
</button>
|
382 |
+
<div class="text-primary">${{ item.Price__c }}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
</div>
|
384 |
</div>
|
|
|
385 |
{% else %}
|
386 |
+
<p>No items in your cart.</p>
|
387 |
{% endfor %}
|
388 |
</div>
|
389 |
+
|
390 |
<!-- Suggestions Section -->
|
391 |
{% if suggestions %}
|
392 |
+
<div class="suggestion-section">
|
393 |
+
<h5>Complete Your Meal</h5>
|
394 |
+
<div class="suggestion-items-container">
|
395 |
+
{% for suggestion in suggestions %}
|
396 |
+
<div class="suggestion-item">
|
397 |
+
<img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
|
398 |
+
<div>
|
399 |
+
<div>{{ suggestion.Name }}</div>
|
400 |
+
<div class="text-muted">${{ suggestion.Price__c }}</div>
|
401 |
+
</div>
|
402 |
+
<button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}', '{{ suggestion.Id }}')">+</button>
|
403 |
+
</div>
|
404 |
+
{% endfor %}
|
405 |
</div>
|
|
|
406 |
</div>
|
|
|
407 |
{% endif %}
|
408 |
+
|
409 |
<!-- Subtotal -->
|
410 |
<div class="cart-summary">
|
411 |
{% if coupons %}
|
412 |
+
<div class="coupon-selection d-flex justify-content-between align-items-center">
|
413 |
+
<label class="text-dark font-weight-bold mb-0">Apply Coupon</label>
|
414 |
+
<a href="javascript:void(0);" id="applyCouponLink" onclick="toggleCouponDropdown()" class="text-primary">+ Apply Coupon</a>
|
415 |
+
</div>
|
416 |
+
<select id="couponDropdown" class="form-select mt-2" style="display:none;" onchange="calculateDiscount()">
|
417 |
+
<option value="">Select a coupon</option>
|
418 |
+
{% for coupon in coupons %}
|
419 |
+
<option value="{{ coupon }}">{{ coupon }}</option>
|
420 |
+
{% endfor %}
|
421 |
+
</select>
|
422 |
{% endif %}
|
423 |
+
|
424 |
<div class="bill-details">
|
425 |
<div class="label">Cart Total</div>
|
426 |
<div class="amount">${{ subtotal }}</div>
|
427 |
<div class="label">Discount</div>
|
428 |
<div class="amount" id="discountText">-${{ discount }}</div>
|
429 |
</div>
|
430 |
+
|
431 |
<div class="dotted-line"></div>
|
432 |
+
|
433 |
<div class="total-bill">
|
434 |
<div class="label">To Pay</div>
|
435 |
<div class="amount" id="totalBillText">${{ subtotal }}</div>
|
|
|
438 |
</div>
|
439 |
</div>
|
440 |
</div>
|
441 |
+
|
442 |
<script>
|
|
|
443 |
function updateQuantity(action, itemName, customerEmail) {
|
444 |
let quantityInput = document.querySelector(`input[data-item-name="${itemName}"]`);
|
445 |
let quantity = parseInt(quantityInput.value);
|
|
|
463 |
quantityInput.value = quantity;
|
464 |
let itemElement = quantityInput.closest(".cart-item");
|
465 |
if (itemElement) {
|
466 |
+
let basePriceElement = itemElement.querySelector(".text-primary");
|
467 |
+
if (basePriceElement && data.new_item_price) {
|
468 |
+
basePriceElement.innerText = `$${data.new_item_price.toFixed(2)}`;
|
469 |
}
|
470 |
}
|
471 |
location.reload();
|
|
|
475 |
})
|
476 |
.catch(err => console.error("Error:", err));
|
477 |
}
|
478 |
+
|
479 |
function toggleCouponDropdown() {
|
480 |
let couponDropdown = document.getElementById('couponDropdown');
|
481 |
+
if (couponDropdown.style.display === "none" || couponDropdown.style.display === "") {
|
482 |
+
couponDropdown.style.display = "block";
|
483 |
+
} else {
|
484 |
+
couponDropdown.style.display = "none";
|
485 |
+
}
|
486 |
}
|
487 |
+
|
488 |
function calculateDiscount() {
|
489 |
let couponDropdown = document.getElementById('couponDropdown');
|
490 |
let selectedCoupon = couponDropdown.value.trim();
|
|
|
499 |
document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
|
500 |
}
|
501 |
}
|
502 |
+
|
503 |
function proceedToOrder() {
|
504 |
let couponDropdown = document.getElementById('couponDropdown');
|
505 |
+
let selectedCoupon = "";
|
506 |
+
if (couponDropdown) {
|
507 |
+
selectedCoupon = couponDropdown.value ? couponDropdown.value.trim() : "";
|
508 |
+
}
|
509 |
+
if (selectedCoupon === "" || selectedCoupon === "None" || selectedCoupon === "Null") {
|
510 |
selectedCoupon = null;
|
511 |
}
|
512 |
+
fetch('/cart/checkout', {
|
513 |
method: 'POST',
|
514 |
headers: { 'Content-Type': 'application/json' },
|
515 |
body: JSON.stringify({ selectedCoupon: selectedCoupon })
|
516 |
})
|
517 |
+
.then(response => response.json())
|
|
|
|
|
|
|
|
|
|
|
518 |
.then(data => {
|
519 |
if (data.success) {
|
520 |
+
alert(data.message);
|
521 |
window.location.href = '/order';
|
522 |
} else {
|
523 |
+
alert(data.error || data.message);
|
524 |
}
|
525 |
})
|
526 |
.catch(err => {
|
527 |
console.error('Error during checkout:', err);
|
528 |
+
alert('An error occurred during checkout. Please try again.');
|
529 |
});
|
530 |
}
|
531 |
+
|
532 |
function removeItemFromCart(itemName) {
|
533 |
fetch(`/cart/remove/${encodeURIComponent(itemName)}`, {
|
534 |
method: 'POST',
|
|
|
545 |
})
|
546 |
.catch(err => console.error('Error removing item:', err));
|
547 |
}
|
548 |
+
|
549 |
function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
|
550 |
const customerEmail = "{{ customer_email }}";
|
551 |
const data = {
|
|
|
568 |
alert('Item added to cart!');
|
569 |
location.reload();
|
570 |
} else {
|
571 |
+
alert('Error adding item to cart: ' + data.error);
|
572 |
}
|
573 |
})
|
574 |
.catch(err => console.error('Error adding item:', err));
|