lokeshloki143 commited on
Commit
4cf365f
·
verified ·
1 Parent(s): 9a5f1c7

Update templates/cart.html

Browse files
Files changed (1) hide show
  1. 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
- body {
11
  font-family: Arial, sans-serif;
12
  background-color: #fdf4e3;
13
  color: #333;
14
- }
15
- .top-bar {
16
- background-color: #FF6F3C;
17
- width: 100%;
18
- padding: 10px 15px;
19
- display: flex;
20
- align-items: center;
21
- box-sizing: border-box;
22
- }
23
- .back-link {
24
- display: flex;
25
- align-items: center;
26
- text-decoration: none;
27
- }
28
- .back-arrow {
29
- font-size: 1.8rem;
30
- color: #000;
31
- font-weight: bold;
32
- }
33
- .back-label {
34
- margin-left: 10px;
35
- color: white;
36
- font-weight: bold;
37
- font-size: 1rem;
38
- }
39
- h1 {
40
- color: #1C1C1C;
41
- font-size: 1.2rem;
42
- margin: 30px 0 15px;
43
- text-align: center;
44
- }
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
- .cart-container {
53
- max-width: 768px;
54
- margin: 20px auto;
55
- padding: 15px;
56
- background-color: #FFFFFF;
57
- border-radius: 10px;
58
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
59
- }
60
- .cart-container2 {
61
- background-color: #FFFFFF;
62
- display: flex;
63
- flex-direction: column;
64
- padding: 10px;
65
- }
66
- .cart-item {
67
- display: flex;
68
- align-items: flex-start;
69
- justify-content: space-between;
70
- border: 1px solid #fdf4e3;
71
- padding: 30px 15px 15px;
72
- background-color: #fff;
73
- box-sizing: border-box;
74
- min-height: 100px;
75
- position: relative;
76
- border-radius: 8px;
77
- }
78
- .remove-btn {
79
- border: none;
80
- background-color: transparent;
81
- cursor: pointer;
82
- font-size: 1.2rem;
83
- margin-bottom: 10px;
84
- transition: color 0.3s ease;
85
- position: relative;
86
- top: -35px;
87
- left: 50px;
88
- }
89
- .remove-btn i {
90
- color: red;
91
- }
92
- .remove-btn:hover {
93
- color: black;
94
- background-color: transparent;
95
- }
96
- .remove-btn:focus {
97
- outline: none;
98
- background-color: transparent;
99
- }
100
- .text-primary {
101
- color: #2e7d32;
102
- text-align: right;
103
- font-weight: bold;
104
- white-space: nowrap;
105
- }
106
- .image-wrapper {
107
- width: 80px;
108
- height: 80px !important;
109
- display: flex;
110
- align-items: center;
111
- justify-content: center;
112
- }
113
- .cart-item img {
114
- width: 70px;
115
- height: 70px;
116
- object-fit: cover;
117
- border-radius: 5px;
118
- border: 1px solid #ffcc80;
119
- margin: 0;
120
- }
121
- .cart-item img:hover {
122
- transform: scale(1.05);
123
- }
124
- .cart-item-title {
125
- font-size: 1.1rem;
126
- font-weight: bold;
127
- }
128
- .checkout-button {
129
- background-color: #FF6F3C; /* Updated to vibrant orange */
130
- color: #ffffff;
131
- padding: 12px;
132
- border-radius: 8px;
133
- border: none;
134
- width: 100%;
135
- font-size: 1rem;
136
- cursor: pointer;
137
- transition: background-color 0.3s, color 0.3s;
138
- }
139
- .checkout-button:hover {
140
- background-color: #E55A2A; /* Slightly darker orange on hover */
141
- color: #ffffff;
142
- }
143
- .add-back-button {
144
- padding: 6px 20px;
145
- font-size: 0.9rem;
146
- border-radius: 20px;
147
- border: 1px solid #fff;
148
- background-color: #fff;
149
- color: #0FAA39;
150
- cursor: pointer;
151
- transition: background-color 0.3s, color 0.3s;
152
- }
153
- .add-back-button:hover {
154
- background-color: #fff;
155
- color: #0FAA39;
156
- }
157
- .cart-item-details {
158
- flex: 1;
159
- margin-left: 15px;
160
- }
161
- .cart-item-quantity {
162
- display: flex;
163
- align-items: center;
164
- margin-top: 5px;
165
- }
166
- .cart-item-quantity button {
167
- width: 24px;
168
- height: 24px;
169
- border: none;
170
- background-color: #f0f0f0;
171
- font-size: 0.8rem;
172
- font-weight: bold;
173
- cursor: pointer;
174
- }
175
- .cart-item-quantity input {
176
- width: 40px;
177
- text-align: center;
178
- border: none;
179
- background-color: #f8f9fa;
180
- font-size: 1rem;
181
- margin: 0 5px;
182
- }
183
- .cart-summary {
184
- position: relative;
185
- text-align: left;
186
- margin-top: 15px;
187
- padding: 20px;
188
- background-color: #fff;
189
- border-radius: 12px;
190
- border: 2px solid #fdf4e3;
191
- box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
192
- }
193
- .cart-item-instructions {
194
- word-wrap: break-word;
195
- white-space: normal;
196
- overflow: hidden;
197
- max-width: 100%;
198
- word-break: break-word;
199
- }
200
- .coupon-selection {
201
- display: flex;
202
- justify-content: space-between;
203
- align-items: center;
204
- font-size: 1rem;
205
- margin-bottom: 20px;
206
- position: relative;
207
- }
208
- .coupon-selection label {
209
- font-weight: bold;
210
- color: black;
211
- }
212
- .coupon-selection a {
213
- color: #007bff;
214
- font-size: 1rem;
215
- text-decoration: none;
216
- text-align: right;
217
- }
218
- #couponDropdown {
219
- width: 30%;
220
- display: none;
221
- background-color: #fff;
222
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
223
- z-index: 10;
224
- margin-top: 10px;
225
- margin-left: auto;
226
- margin-right: 0;
227
- }
228
- #couponDropdown.show {
229
- display: block;
230
- }
231
- .bill-details {
232
- display: grid;
233
- grid-template-columns: 1fr 1fr;
234
- grid-gap: 10px;
235
- margin-bottom: 10px;
236
- }
237
- .bill-details .label {
238
- font-weight: 600;
239
- font-size: 1rem;
240
- }
241
- .bill-details .amount {
242
- text-align: right;
243
- font-weight: 600;
244
- font-size: 1rem;
245
- }
246
- .dotted-line {
247
- border-bottom: 2px dotted #ccc;
248
- margin: 15px 0;
249
- }
250
- .total-bill {
251
- display: grid;
252
- grid-template-columns: 1fr 1fr;
253
- font-weight: 600;
254
- font-size: 1.2rem;
255
- margin-top: 10px;
256
- margin-bottom: 10px;
257
- }
258
- .total-bill .label {
259
- font-size: 1.1rem;
260
- }
261
- .total-bill .amount {
262
- text-align: right;
263
- font-size: 1.1rem;
264
- color: #2e7d32;
265
- }
266
- .cart-summary.has-dropdown {
267
- margin-bottom: 80px;
268
- }
269
- .suggestion-section {
270
- margin-top: 25px;
271
- padding: 15px;
272
- background-color: #fff;
273
- border-radius: 10px;
274
- border: 2px solid #fdf4e3;
275
- }
276
- .suggestion-items-container {
277
- display: flex;
278
- overflow-x: auto;
279
- gap: 10px;
280
- padding-bottom: 10px;
281
- padding-top: 10px;
282
- }
283
- .suggestion-item {
284
- display: flex;
285
- align-items: center;
286
- justify-content: flex-start;
287
- flex-shrink: 0;
288
- width: 160px;
289
- padding: 10px;
290
- border-radius: 8px;
291
- background-color: #fff;
292
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
293
- transition: transform 0.3s ease;
294
- margin-right: 10px;
295
- position: relative;
296
- text-align: left;
297
- overflow: visible;
298
- border: 2px solid #fdf4e3;
299
- }
300
- .suggestion-item:hover {
301
- transform: scale(1.05);
302
- }
303
- .suggestion-item img {
304
- width: 50px;
305
- height: 50px;
306
- object-fit: cover;
307
- border-radius: 5px;
308
- margin-right: 12px;
309
- }
310
- .suggestion-item div {
311
- flex-grow: 1;
312
- text-align: left;
313
- }
314
- .add-back-button {
315
- position: absolute;
316
- top: -5px;
317
- right: -10px;
318
- font-size: 1rem;
319
- padding: 0;
320
- width: 30px;
321
- height: 30px;
322
- background-color: #fff;
323
- color: #0FAA39;
324
- border: 2px solid #0FAA39;
325
- border-radius: 0;
326
- cursor: pointer;
327
- transition: background-color 0.3s, color 0.3s, border-color 0.3s;
328
- z-index: 2;
329
- }
330
- .add-back-button:hover {
331
- background-color: #fff;
332
- color: #0FAA39;
333
- border-color: #0FAA39;
334
- z-index: 3;
335
- }
336
- .suggestion-items-container::-webkit-scrollbar {
337
- height: 8px;
338
- }
339
- .suggestion-items-container::-webkit-scrollb
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
- <!-- Order History Title (centered and dark black) -->
372
- <div class="order-heading">Your Cart</umt>
 
 
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
- <div class="cart-item">
379
- <div class="image-wrapper">
380
- <img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
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-instructions">
388
- <small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
 
 
 
 
 
 
 
 
 
 
 
389
  </div>
390
- <div class="cart-item-quantity mt-2">
391
- <button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
392
- <input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
393
- <button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
394
- </div>
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
- <p>No items in your cart.</p>
408
  {% endfor %}
409
  </div>
 
410
  <!-- Suggestions Section -->
411
  {% if suggestions %}
412
- <div class="suggestion-section">
413
- <h5>Complete Your Meal</h5>
414
- <div class="suggestion-items-container">
415
- {% for suggestion in suggestions %}
416
- <div class="suggestion-item">
417
- <img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
418
- <div>
419
- <div>{{ suggestion.Name }}</div>
420
- <div class="text-muted">${{ suggestion.Price__c }}</div>
421
- </div>
422
- <button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}', '{{ suggestion.Id }}')">+</button>
 
 
423
  </div>
424
- {% endfor %}
425
  </div>
426
- </div>
427
  {% endif %}
 
428
  <!-- Subtotal -->
429
  <div class="cart-summary">
430
  {% if coupons %}
431
- <div class="coupon-selection d-flex justify-content-between align-items-center">
432
- <label class="text-dark font-weight-bold mb-0">Apply Coupon</label>
433
- <a href="javascript:void(0);" id="applyCouponLink" onclick="toggleCouponDropdown()" class="text-primary">+ Apply Coupon</a>
434
- </div>
435
- <select id="couponDropdown" class="form-select mt-2" style="display:none;" onchange="calculateDiscount()">
436
- <option value="">Select a coupon</option>
437
- {% for coupon in coupons %}
438
- <option value="{{ coupon }}">{{ coupon }}</option>
439
- {% endfor %}
440
- </select>
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(".base-price");
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
- // Toggle coupon dropdown
495
  function toggleCouponDropdown() {
496
  let couponDropdown = document.getElementById('couponDropdown');
497
- couponDropdown.style.display = couponDropdown.style.display === "none" || couponDropdown.style.display === "" ? "block" : "none";
 
 
 
 
498
  }
499
- // Calculate discount
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
- // Proceed to Order
515
  function proceedToOrder() {
516
  let couponDropdown = document.getElementById('couponDropdown');
517
- let selectedCoupon = couponDropdown && couponDropdown.value ? couponDropdown.value.trim() : null;
518
- if (selectedCoupon === "" || selectedCoupon.toLowerCase() === "none") {
 
 
 
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 || "Order processed successfully!");
535
  window.location.href = '/order';
536
  } else {
537
- alert(data.error || "Failed to process order. Please try again.");
538
  }
539
  })
540
  .catch(err => {
541
  console.error('Error during checkout:', err);
542
- alert("An error occurred while processing your order. Please try again.");
543
  });
544
  }
545
- // Remove item from cart
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
- // Add suggestion to cart
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
- alert('Error adding item to cart: ' + data.error);
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));