lokeshloki143 commited on
Commit
1b42973
·
verified ·
1 Parent(s): 73513f6

Update templates/cart.html

Browse files
Files changed (1) hide show
  1. templates/cart.html +44 -832
templates/cart.html CHANGED
@@ -4,9 +4,7 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
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 {
@@ -14,15 +12,12 @@
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;
@@ -40,8 +35,6 @@
40
  font-weight: bold;
41
  font-size: 1rem;
42
  }
43
-
44
- /* Title Styling */
45
  .order-heading {
46
  color: #000;
47
  font-size: 2.5rem;
@@ -49,7 +42,6 @@
49
  text-align: center;
50
  margin-top: 30px;
51
  }
52
-
53
  .cart-container {
54
  max-width: 768px;
55
  margin: 20px auto;
@@ -58,55 +50,26 @@
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;
@@ -117,53 +80,22 @@
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
- font-size: 1rem;
150
- padding: 0;
151
- width: 30px;
152
- height: 30px;
153
- background-color: #fff;
154
- color: #0FAA39;
155
- border: 2px solid #0FAA39;
156
- border-radius: 50%;
157
- cursor: pointer;
158
- transition: background-color 0.3s, color 0.3s, border-color 0.3s;
159
- }
160
- .add-back-button:hover {
161
- background-color: #0FAA39;
162
- color: #fff;
163
- }
164
- .cart-item-details {
165
- flex: 1;
166
- margin-left: 15px;
167
  }
168
  .cart-item-quantity {
169
  display: flex;
@@ -188,52 +120,12 @@
188
  margin: 0 5px;
189
  }
190
  .cart-summary {
191
- position: relative;
192
  text-align: left;
193
  margin-top: 15px;
194
  padding: 20px;
195
  background-color: #fff;
196
  border-radius: 12px;
197
  border: 2px solid #fdf4e3;
198
- box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
199
- }
200
- .cart-item-instructions {
201
- word-wrap: break-word;
202
- white-space: normal;
203
- overflow: hidden;
204
- max-width: 100%;
205
- word-break: break-word;
206
- }
207
- .coupon-selection {
208
- display: flex;
209
- justify-content: space-between;
210
- align-items: center;
211
- font-size: 1rem;
212
- margin-bottom: 20px;
213
- position: relative;
214
- }
215
- .coupon-selection label {
216
- font-weight: bold;
217
- color: black;
218
- }
219
- .coupon-selection a {
220
- color: #007bff;
221
- font-size: 1rem;
222
- text-decoration: none;
223
- text-align: right;
224
- }
225
- #couponDropdown {
226
- width: 30%;
227
- display: none;
228
- background-color: #fff;
229
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
230
- z-index: 10;
231
- margin-top: 10px;
232
- margin-left: auto;
233
- margin-right: 0;
234
- }
235
- #couponDropdown.show {
236
- display: block;
237
  }
238
  .bill-details {
239
  display: grid;
@@ -259,287 +151,25 @@
259
  grid-template-columns: 1fr 1fr;
260
  font-weight: 600;
261
  font-size: 1.2rem;
262
- margin-top: 10px;
263
- margin-bottom: 10px;
264
- }
265
- .total-bill .label {
266
- font-size: 1.1rem;
267
  }
268
  .total-bill .amount {
269
  text-align: right;
270
- font-size: 1.1rem;
271
  color: #2e7d32;
272
  }
273
- .cart-summary.has-dropdown {
274
- margin-bottom: 80px;
275
- }
276
- .suggestion-section {
277
- margin-top: 25px;
278
- padding: 15px;
279
- background-color: #fff;
280
- border-radius: 10px;
281
- border: 2px solid #fdf4e3;
282
- }
283
- .suggestion-items-container {
284
- display: flex;
285
- overflow-x: auto;
286
- gap: 10px;
287
- padding-bottom: 10px;
288
- padding-top: 10px;
289
- }
290
- .suggestion-item {
291
- display: flex;
292
- align-items: center;
293
- justify-content: flex-start;
294
- flex-shrink: 0;
295
- width: 160px;
296
- padding: 10px;
297
- border-radius: 8px;
298
- background-color: #fff;
299
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
300
- transition: transform 0.3s ease;
301
- margin-right: 10px;
302
- position: relative;
303
- text-align: left;
304
- overflow: visible;
305
- border: 2px solid #fdf4e3;
306
- }
307
- .suggestion-item:hover {
308
- transform: scale(1.05);
309
- }
310
- .suggestion-item img {
311
- width: 50px;
312
- height: 50px;
313
- object-fit: cover;
314
- border-radius: 5px;
315
- margin-right: 12px;
316
- }
317
- .suggestion-item div {
318
- flex-grow: 1;
319
- text-align: left;
320
- }
321
- .suggestion-items-container::-webkit-scrollbar {
322
- height: 8px;
323
- }
324
- .suggestion-items-container::-webkit-scrollbar-thumb {
325
- background-color: #fff;
326
- border-radius: 4px;
327
- }
328
- .suggestion-items-container::-webkit-scrollbar-track {
329
- background-color: #f1f1f1;
330
- }
331
- .cart-item-actions {
332
- display: flex;
333
- align-items: flex-start;
334
- margin-left: auto;
335
- }
336
-
337
- /* Modal Styles */
338
- .modal {
339
- display: none;
340
- position: fixed;
341
- top: 0;
342
- left: 0;
343
- width: 100%;
344
- height: 100%;
345
- background-color: rgba(0, 0, 0, 0.5);
346
- z-index: 1000;
347
- justify-content: center;
348
- align-items: center;
349
- }
350
- .modal-content {
351
- background-color: #fff;
352
- padding: 20px;
353
- border-radius: 10px;
354
- width: 90%;
355
- max-width: 600px;
356
- max-height: 80vh;
357
- overflow-y: auto;
358
- position: relative;
359
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
360
- }
361
- .modal-content h3 {
362
- text-align: center;
363
- margin-bottom: 20px;
364
- color: #333;
365
- }
366
- .close-modal {
367
- position: absolute;
368
- top: 10px;
369
- right: 15px;
370
- font-size: 1.5rem;
371
- cursor: pointer;
372
- color: #333;
373
- }
374
- .menu-items-container {
375
- display: flex;
376
- flex-wrap: wrap;
377
- gap: 10px;
378
- padding: 10px;
379
- }
380
- .menu-item {
381
- display: flex;
382
- align-items: center;
383
- justify-content: space-between;
384
- width: calc(50% - 10px);
385
- padding: 10px;
386
  border-radius: 8px;
387
- background-color: #fff;
388
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
389
- border: 2px solid #fdf4e3;
390
- position: relative;
391
- min-height: 70px;
392
- }
393
- .menu-item img {
394
- width: 50px;
395
- height: 50px;
396
- object-fit: cover;
397
- border-radius: 5px;
398
- margin-right: 10px;
399
- border: 1px solid #ffcc80;
400
- }
401
- .menu-item:hover img {
402
- transform: scale(1.05);
403
- }
404
- .menu-item-details {
405
- flex-grow: 1;
406
- font-size: 0.9rem;
407
- }
408
- .menu-item-details strong {
409
- font-size: 1rem;
410
- }
411
- .menu-item-details small {
412
- display: block;
413
- color: #666;
414
- font-size: 0.8rem;
415
- }
416
- .quantity-selector {
417
- display: none;
418
- align-items: center;
419
- }
420
- .quantity-selector button {
421
- width: 28px;
422
- height: 28px;
423
  border: none;
424
- background-color: #f0f0f0;
425
  font-size: 1rem;
426
- font-weight: bold;
427
  cursor: pointer;
428
- border-radius: 4px;
429
- }
430
- .quantity-selector input {
431
- width: 40px;
432
- text-align: center;
433
- border: none;
434
- background-color: #f8f9fa;
435
- font-size: 1rem;
436
- margin: 0 5px;
437
- border-radius: 4px;
438
- }
439
- .customization-section {
440
- display: none;
441
- position: absolute;
442
- top: 100%;
443
- left: 0;
444
- right: 0;
445
- background-color: #fff;
446
- padding: 15px;
447
- border-radius: 8px;
448
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
449
- z-index: 10;
450
- border: 2px solid #fdf4e3;
451
- max-height: 300px;
452
- overflow-y: auto;
453
- }
454
- .customization-section.show {
455
- display: block;
456
- }
457
- .customization-section h4 {
458
- font-size: 1.2rem;
459
- margin-bottom: 10px;
460
- }
461
- .customization-section label {
462
- display: block;
463
- margin-bottom: 5px;
464
- font-size: 0.9rem;
465
- }
466
- .customization-section textarea {
467
- width: 100%;
468
- height: 60px;
469
- margin-top: 10px;
470
- padding: 5px;
471
- border: 1px solid #ccc;
472
- border-radius: 5px;
473
- font-size: 0.9rem;
474
- }
475
- .customization-actions {
476
- display: flex;
477
- justify-content: space-between;
478
  margin-top: 15px;
479
  }
480
- .customization-actions button {
481
- padding: 8px;
482
- border: none;
483
- border-radius: 5px;
484
- cursor: pointer;
485
- width: 48%;
486
- text-align: center;
487
- font-size: 0.9rem;
488
- color: #fff;
489
- }
490
- .add-to-cart-btn {
491
- background-color: #A52A2A;
492
- }
493
- .cancel-customization-btn {
494
- background-color: #6c757d;
495
- }
496
- .bill-item {
497
- display: flex;
498
- justify-content: space-between;
499
- padding: 10px 0;
500
- border-bottom: 1px solid #f0f0f0;
501
- }
502
- .bill-item-details {
503
- flex: 1;
504
- }
505
- .bill-item-details small {
506
- display: block;
507
- color: #666;
508
- }
509
- .bill-item-price {
510
- font-weight: bold;
511
- color: #2e7d32;
512
- }
513
- .bill-summary {
514
- margin-top: 20px;
515
- }
516
- .modal-actions {
517
- display: flex;
518
- justify-content: space-between;
519
- margin-top: 20px;
520
- }
521
- .action-btn {
522
- padding: 10px;
523
- border: none;
524
- border-radius: 8px;
525
- cursor: pointer;
526
- width: 48%;
527
- text-align: center;
528
- color: #fff;
529
- }
530
- .view-bill-btn {
531
- background-color: #A52A2A;
532
- }
533
- .cancel-btn {
534
- background-color: #6c757d;
535
- }
536
- .confirm-order-btn {
537
- background-color: #A52A2A;
538
- }
539
  </style>
540
  </head>
541
  <body>
542
- <!-- Top Orange Label Bar -->
543
  <div class="top-bar">
544
  <a href="/menu" class="back-link">
545
  <span class="back-arrow">⟨</span>
@@ -547,161 +177,56 @@
547
  </a>
548
  </div>
549
 
550
- <!-- Order History Title -->
551
  <div class="order-heading">Your Cart</div>
552
 
553
  <div class="container">
554
  <div class="cart-container">
555
- <div class="cart-container2">
556
- {% for item in cart_items %}
557
- <div class="cart-item">
558
- <div class="image-wrapper">
559
- <img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
 
 
 
 
560
  </div>
561
- <div class="cart-item-details">
562
- <div class="cart-item-title">{{ item.Name }}</div>
563
- <div class="cart-item-addons">
564
- <small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
565
- </div>
566
- <div class="cart-item-instructions">
567
- <small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
568
- </div>
569
- <div class="cart-item-quantity mt-2">
570
- <button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
571
- <input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
572
- <button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
573
- </div>
574
  </div>
575
- <div class="cart-item-actions">
576
- <button type="button" class="btn btn-light text-dark remove-btn" onclick="removeItemFromCart('{{ item.Name }}')">
577
- <i class="bi bi-trash"></i>
578
- </button>
579
- <div class="text-primary">${{ item.Price__c }}</div>
580
  </div>
581
  </div>
582
- {% else %}
583
- <p>No items in your cart.</p>
584
- {% endfor %}
585
- </div>
586
-
587
- <!-- Suggestions Section -->
588
- {% if suggestions %}
589
- <div class="suggestion-section">
590
- <h5>Complete Your Meal</h5>
591
- <div class="suggestion-items-container">
592
- {% for suggestion in suggestions %}
593
- <div class="suggestion-item">
594
- <img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
595
- <div>
596
- <div>{{ suggestion.Name }}</div>
597
- <div class="text-muted">${{ suggestion.Price__c }}</div>
598
- </div>
599
- <button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}')">+</button>
600
- </div>
601
- {% endfor %}
602
  </div>
603
  </div>
604
- {% endif %}
 
 
605
 
606
- <!-- Subtotal -->
607
  <div class="cart-summary">
608
- {% if coupons %}
609
- <div class="coupon-selection d-flex justify-content-between align-items-center">
610
- <label class="text-dark font-weight-bold mb-0">Apply Coupon</label>
611
- <a href="javascript:void(0);" id="applyCouponLink" onclick="toggleCouponDropdown()" class="text-primary">+ Apply Coupon</a>
612
- </div>
613
- <select id="couponDropdown" class="form-select mt-2" style="display:none;" onchange="calculateDiscount()">
614
- <option value="">Select a coupon</option>
615
- {% for coupon in coupons %}
616
- <option value="{{ coupon }}">{{ coupon }}</option>
617
- {% endfor %}
618
- </select>
619
- {% endif %}
620
-
621
- <div class="bill-details">
622
- <div class="label">Cart Total</div>
623
- <div class="amount">${{ subtotal }}</div>
624
- <div class="label">Discount</div>
625
- <div class="amount" id="discountText">-${{ discount }}</div>
626
- </div>
627
-
628
- <div class="dotted-line"></div>
629
-
630
- <div class="total-bill">
631
- <div class="label">To Pay</div>
632
- <div class="amount" id="totalBillText">${{ subtotal }}</div>
633
- </div>
634
- <button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
635
- </div>
636
- </div>
637
- </div>
638
-
639
- <!-- Anything Else Modal -->
640
- <div class="modal" id="anythingElseModal">
641
- <div class="modal-content">
642
- <span class="close-modal" onclick="closeAnythingElseModal()">×</span>
643
- <h3>Anything Else You Want?</h3>
644
- <div class="menu-items-container" id="menuItems"></div>
645
- <div class="modal-actions">
646
- <button class="action-btn view-bill-btn" onclick="showBill()">View Bill</button>
647
- <button class="action-btn cancel-btn" onclick="closeAnythingElseModal()">Cancel</button>
648
- </div>
649
- </div>
650
- </div>
651
-
652
- <!-- Bill Modal -->
653
- <div class="modal" id="billModal">
654
- <div class="modal-content">
655
- <span class="close-modal" onclick="closeBillModal()">×</span>
656
- <h3>Your Bill</h3>
657
- <div id="billItems"></div>
658
- <div class="bill-summary">
659
  <div class="bill-details">
660
  <div class="label">Subtotal</div>
661
- <div class="amount" id="billSubtotal">$0.00</div>
662
- <div class="label">Discount</div>
663
- <div class="amount" id="billDiscount">$0.00</div>
664
  </div>
665
  <div class="dotted-line"></div>
666
  <div class="total-bill">
667
  <div class="label">Total</div>
668
- <div class="amount" id="billTotal">$0.00</div>
669
  </div>
670
- </div>
671
- <div class="modal-actions">
672
- <button class="action-btn confirm-order-btn" onclick="submitOrder()">Confirm Order</button>
673
- <button class="action-btn cancel-btn" onclick="closeBillModal()">Cancel</button>
674
  </div>
675
  </div>
676
  </div>
677
 
678
  <script>
679
- let currentCart = null;
680
- let menuItems = [];
681
- let selectedItem = null;
682
- let availableAddOns = [];
683
-
684
- // Fetch add-ons when the modal is opened
685
- function fetchAddOns() {
686
- return fetch('/cart/fetch_add_ons', {
687
- method: 'GET',
688
- headers: { 'Content-Type': 'application/json' }
689
- })
690
- .then(response => response.json())
691
- .then(data => {
692
- if (data.success) {
693
- availableAddOns = data.add_ons;
694
- } else {
695
- console.error('Error fetching add-ons:', data.error);
696
- availableAddOns = [];
697
- }
698
- })
699
- .catch(err => {
700
- console.error('Error fetching add-ons:', err);
701
- availableAddOns = [];
702
- });
703
- }
704
-
705
  function updateQuantity(action, itemName, customerEmail) {
706
  let quantityInput = document.querySelector(`input[data-item-name="${itemName}"]`);
707
  let quantity = parseInt(quantityInput.value);
@@ -723,13 +248,6 @@
723
  .then(data => {
724
  if (data.success) {
725
  quantityInput.value = quantity;
726
- let itemElement = quantityInput.closest(".cart-item");
727
- if (itemElement) {
728
- let basePriceElement = itemElement.querySelector(".text-primary");
729
- if (basePriceElement && data.new_item_price) {
730
- basePriceElement.innerText = `$${data.new_item_price.toFixed(2)}`;
731
- }
732
- }
733
  location.reload();
734
  } else {
735
  alert("Error updating quantity: " + data.error);
@@ -738,288 +256,6 @@
738
  .catch(err => console.error("Error:", err));
739
  }
740
 
741
- function toggleCouponDropdown() {
742
- let couponDropdown = document.getElementById('couponDropdown');
743
- if (couponDropdown.style.display === "none" || couponDropdown.style.display === "") {
744
- couponDropdown.style.display = "block";
745
- } else {
746
- couponDropdown.style.display = "none";
747
- }
748
- }
749
-
750
- function calculateDiscount() {
751
- let couponDropdown = document.getElementById('couponDropdown');
752
- let selectedCoupon = couponDropdown.value.trim();
753
- let subtotal = parseFloat("{{ subtotal }}");
754
- if (selectedCoupon && selectedCoupon.toLowerCase() !== "none") {
755
- let discount = subtotal * 0.10;
756
- let total = subtotal - discount;
757
- document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
758
- document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
759
- } else {
760
- document.getElementById("discountText").innerText = `$0.00`;
761
- document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
762
- }
763
- }
764
-
765
- function proceedToOrder() {
766
- let couponDropdown = document.getElementById('couponDropdown');
767
- let selectedCoupon = "";
768
- if (couponDropdown) {
769
- selectedCoupon = couponDropdown.value ? couponDropdown.value.trim() : "";
770
- }
771
- if (selectedCoupon === "" || selectedCoupon === "None" || selectedCoupon === "Null") {
772
- selectedCoupon = null;
773
- }
774
- // Fetch add-ons before displaying the modal
775
- fetchAddOns().then(() => {
776
- fetch('/cart/checkout', {
777
- method: 'POST',
778
- headers: { 'Content-Type': 'application/json' },
779
- body: JSON.stringify({ selectedCoupon: selectedCoupon })
780
- })
781
- .then(response => response.json())
782
- .then(data => {
783
- if (data.success) {
784
- currentCart = data.cart;
785
- menuItems = data.menu_items;
786
- displayAnythingElse();
787
- } else {
788
- alert(data.error || data.message);
789
- }
790
- })
791
- .catch(err => {
792
- console.error('Error during checkout:', err);
793
- alert('An error occurred. Please try again.');
794
- });
795
- });
796
- }
797
-
798
- function displayAnythingElse() {
799
- const menuItemsContainer = document.getElementById('menuItems');
800
- menuItemsContainer.innerHTML = '';
801
- menuItems.forEach(item => {
802
- const itemElement = document.createElement('div');
803
- itemElement.className = 'menu-item';
804
- itemElement.innerHTML = `
805
- <img src="${item.Image1__c}" alt="${item.Name}" onerror="this.src='/static/placeholder.jpg';">
806
- <div class="menu-item-details">
807
- <strong>${item.Name}</strong>
808
- <small>${item.Veg_NonVeg__c} | ${item.Section__c}</small>
809
- <small>$${item.Price__c.toFixed(2)}</small>
810
- </div>
811
- <button class="add-back-button" onclick="showQuantitySelector('${item.Name}', ${item.Price__c}, '${item.Image1__c}', this)">+</button>
812
- <div class="quantity-selector" data-item-name="${item.Name}">
813
- <button onclick="updateMenuItemQuantity('${item.Name}', 'decrease')">-</button>
814
- <input type="text" value="1" readonly data-item-name="${item.Name}">
815
- <button onclick="updateMenuItemQuantity('${item.Name}', 'increase')">+</button>
816
- </div>
817
- <div class="customization-section" data-item-name="${item.Name}">
818
- <h4>Customize ${item.Name}</h4>
819
- <div id="addOns-${item.Name}">
820
- <!-- Add-ons will be populated dynamically -->
821
- </div>
822
- <div>
823
- <strong>Special Instructions</strong>
824
- <textarea placeholder="e.g., Less spicy"></textarea>
825
- </div>
826
- <div class="customization-actions">
827
- <button class="add-to-cart-btn" onclick="addToCartWithCustomizations('${item.Name}', ${item.Price__c}, '${item.Image1__c}')">Add to Cart</button>
828
- <button class="cancel-customization-btn" onclick="cancelCustomization('${item.Name}')">Cancel</button>
829
- </div>
830
- </div>
831
- `;
832
- menuItemsContainer.appendChild(itemElement);
833
- // Populate add-ons for this item
834
- const addOnsContainer = document.getElementById(`addOns-${item.Name}`);
835
- addOnsContainer.innerHTML = `
836
- <strong>Add-Ons</strong>
837
- ${availableAddOns.length > 0 ? availableAddOns.map(addon => `
838
- <label>
839
- <input type="checkbox" value="${addon.name}" data-price="${addon.price}">
840
- ${addon.name}
841
- </label>
842
- `).join('') : '<p>No add-ons available</p>'}
843
- `;
844
- });
845
- document.getElementById('anythingElseModal').style.display = 'flex';
846
- }
847
-
848
- function showQuantitySelector(itemName, itemPrice, itemImage, buttonElement) {
849
- // Hide all quantity selectors and customization sections
850
- document.querySelectorAll('.quantity-selector').forEach(selector => {
851
- selector.style.display = 'none';
852
- selector.querySelector('input').value = 1; // Reset quantity
853
- });
854
- document.querySelectorAll('.customization-section').forEach(section => {
855
- section.classList.remove('show');
856
- section.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
857
- checkbox.checked = false; // Reset add-ons
858
- });
859
- section.querySelector('textarea').value = ''; // Reset instructions
860
- });
861
- document.querySelectorAll('.add-back-button').forEach(btn => {
862
- btn.style.display = 'inline-block';
863
- });
864
-
865
- // Show quantity selector and customization for the clicked item
866
- const quantitySelector = buttonElement.nextElementSibling;
867
- quantitySelector.style.display = 'flex';
868
- buttonElement.style.display = 'none';
869
-
870
- const customizationSection = quantitySelector.nextElementSibling;
871
- customizationSection.classList.add('show');
872
-
873
- selectedItem = { name: itemName, price: itemPrice, image: itemImage };
874
- }
875
-
876
- function updateMenuItemQuantity(itemName, action) {
877
- const quantityInput = document.querySelector(`.quantity-selector[data-item-name="${itemName}"] input`);
878
- let quantity = parseInt(quantityInput.value);
879
- if (action === 'increase') {
880
- quantity++;
881
- } else if (action === 'decrease' && quantity > 1) {
882
- quantity--;
883
- }
884
- if (isNaN(quantity) || quantity < 1) {
885
- quantity = 1;
886
- }
887
- quantityInput.value = quantity;
888
- }
889
-
890
- function cancelCustomization(itemName) {
891
- const quantitySelector = document.querySelector(`.quantity-selector[data-item-name="${itemName}"]`);
892
- const customizationSection = quantitySelector.nextElementSibling;
893
- const addButton = quantitySelector.previousElementSibling;
894
-
895
- // Reset quantity
896
- quantitySelector.querySelector('input').value = 1;
897
- // Hide quantity selector and customization section
898
- quantitySelector.style.display = 'none';
899
- customizationSection.classList.remove('show');
900
- // Show add button
901
- addButton.style.display = 'inline-block';
902
- // Reset add-ons and instructions
903
- customizationSection.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
904
- checkbox.checked = false;
905
- });
906
- customizationSection.querySelector('textarea').value = '';
907
- }
908
-
909
- function addToCartWithCustomizations(itemName, itemPrice, itemImage) {
910
- const quantitySelector = document.querySelector(`.quantity-selector[data-item-name="${itemName}"]`);
911
- const quantity = parseInt(quantitySelector.querySelector('input').value);
912
- if (isNaN(quantity) || quantity < 1) {
913
- alert('Invalid quantity!');
914
- return;
915
- }
916
- const customizationSection = document.querySelector(`.customization-section[data-item-name="${itemName}"]`);
917
- const addOns = Array.from(customizationSection.querySelectorAll('input[type="checkbox"]:checked')).map(checkbox => checkbox.value);
918
- const instructions = customizationSection.querySelector('textarea').value.trim();
919
- const customerEmail = "{{ customer_email }}";
920
-
921
- const data = {
922
- item_name: itemName,
923
- item_price: itemPrice,
924
- item_image: itemImage,
925
- addons: addOns,
926
- instructions: instructions,
927
- customer_email: customerEmail,
928
- quantity: quantity
929
- };
930
-
931
- fetch('/cart/add_suggestion_to_cart', {
932
- method: 'POST',
933
- headers: { 'Content-Type': 'application/json' },
934
- body: JSON.stringify(data)
935
- })
936
- .then(response => response.json())
937
- .then(data => {
938
- if (data.success) {
939
- alert('Item added to cart!');
940
- location.reload();
941
- } else {
942
- alert('Error adding item to cart: ' + data.error);
943
- }
944
- })
945
- .catch(err => {
946
- console.error('Error adding item:', err);
947
- alert('An error occurred while adding the item to the cart.');
948
- });
949
- }
950
-
951
- function closeAnythingElseModal() {
952
- document.getElementById('anythingElseModal').style.display = 'none';
953
- // Reset all quantity selectors and customization sections
954
- document.querySelectorAll('.quantity-selector').forEach(selector => {
955
- selector.style.display = 'none';
956
- selector.querySelector('input').value = 1;
957
- });
958
- document.querySelectorAll('.customization-section').forEach(section => {
959
- section.classList.remove('show');
960
- section.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
961
- checkbox.checked = false;
962
- });
963
- section.querySelector('textarea').value = '';
964
- });
965
- document.querySelectorAll('.add-back-button').forEach(btn => {
966
- btn.style.display = 'inline-block';
967
- });
968
- }
969
-
970
- function showBill() {
971
- closeAnythingElseModal();
972
- const billItemsContainer = document.getElementById('billItems');
973
- billItemsContainer.innerHTML = '';
974
- currentCart.items.forEach(item => {
975
- const itemElement = document.createElement('div');
976
- itemElement.className = 'bill-item';
977
- itemElement.innerHTML = `
978
- <div class="bill-item-details">
979
- <strong>${item.name} x${item.quantity}</strong>
980
- <small>Add-ons: ${item.addons}</small>
981
- <small>Instructions: ${item.instructions}</small>
982
- </div>
983
- <div class="bill-item-price">$${item.price.toFixed(2)}</div>
984
- `;
985
- billItemsContainer.appendChild(itemElement);
986
- });
987
- document.getElementById('billSubtotal').innerText = `$${currentCart.subtotal.toFixed(2)}`;
988
- document.getElementById('billDiscount').innerText = `$${currentCart.discount.toFixed(2)}`;
989
- document.getElementById('billTotal').innerText = `$${currentCart.total.toFixed(2)}`;
990
- document.getElementById('billModal').style.display = 'flex';
991
- }
992
-
993
- function closeBillModal() {
994
- document.getElementById('billModal').style.display = 'none';
995
- currentCart = null;
996
- }
997
-
998
- function submitOrder() {
999
- if (!currentCart) {
1000
- alert('No cart data available.');
1001
- return;
1002
- }
1003
- fetch('/cart/submit_order', {
1004
- method: 'POST',
1005
- headers: { 'Content-Type': 'application/json' },
1006
- body: JSON.stringify({ cart: currentCart })
1007
- })
1008
- .then(response => response.json())
1009
- .then(data => {
1010
- if (data.success) {
1011
- alert(data.message);
1012
- window.location.href = '/order';
1013
- } else {
1014
- alert(data.error || data.message);
1015
- }
1016
- })
1017
- .catch(err => {
1018
- console.error('Error during order submission:', err);
1019
- alert('An error occurred during order submission. Please try again.');
1020
- });
1021
- }
1022
-
1023
  function removeItemFromCart(itemName) {
1024
  fetch(`/cart/remove/${encodeURIComponent(itemName)}`, {
1025
  method: 'POST',
@@ -1037,32 +273,8 @@
1037
  .catch(err => console.error('Error removing item:', err));
1038
  }
1039
 
1040
- function addToCartSuggestion(itemName, itemPrice, itemImage) {
1041
- const customerEmail = "{{ customer_email }}";
1042
- const data = {
1043
- item_name: itemName,
1044
- item_price: itemPrice,
1045
- item_image: itemImage,
1046
- addons: [],
1047
- instructions: "",
1048
- customer_email: customerEmail,
1049
- quantity: 1
1050
- };
1051
- fetch('/cart/add_suggestion_to_cart', {
1052
- method: 'POST',
1053
- headers: { 'Content-Type': 'application/json' },
1054
- body: JSON.stringify(data)
1055
- })
1056
- .then(response => response.json())
1057
- .then(data => {
1058
- if (data.success) {
1059
- alert('Item added to cart!');
1060
- location.reload();
1061
- } else {
1062
- alert('Error adding item to cart: ' + data.error);
1063
- }
1064
- })
1065
- .catch(err => console.error('Error adding item:', err));
1066
  }
1067
  </script>
1068
  </body>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Cart</title>
 
7
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
 
8
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
9
  <style>
10
  body {
 
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
  }
22
  .back-link {
23
  display: flex;
 
35
  font-weight: bold;
36
  font-size: 1rem;
37
  }
 
 
38
  .order-heading {
39
  color: #000;
40
  font-size: 2.5rem;
 
42
  text-align: center;
43
  margin-top: 30px;
44
  }
 
45
  .cart-container {
46
  max-width: 768px;
47
  margin: 20px auto;
 
50
  border-radius: 10px;
51
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
52
  }
 
 
 
 
 
 
53
  .cart-item {
54
  display: flex;
55
  align-items: flex-start;
56
  justify-content: space-between;
57
  border: 1px solid #fdf4e3;
58
+ padding: 15px;
59
  background-color: #fff;
 
 
 
60
  border-radius: 8px;
61
+ margin-bottom: 10px;
62
  }
63
  .remove-btn {
64
  border: none;
65
  background-color: transparent;
66
  cursor: pointer;
67
  font-size: 1.2rem;
 
 
 
 
 
 
 
68
  color: red;
69
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  .image-wrapper {
71
  width: 80px;
72
+ height: 80px;
73
  display: flex;
74
  align-items: center;
75
  justify-content: center;
 
80
  object-fit: cover;
81
  border-radius: 5px;
82
  border: 1px solid #ffcc80;
 
83
  }
84
  .cart-item img:hover {
85
  transform: scale(1.05);
86
  }
87
+ .cart-item-details {
88
+ flex: 1;
89
+ margin-left: 15px;
90
+ }
91
  .cart-item-title {
92
  font-size: 1.1rem;
93
  font-weight: bold;
94
  }
95
+ .text-primary {
96
+ color: #2e7d32;
97
+ text-align: right;
98
+ font-weight: bold;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
  .cart-item-quantity {
101
  display: flex;
 
120
  margin: 0 5px;
121
  }
122
  .cart-summary {
 
123
  text-align: left;
124
  margin-top: 15px;
125
  padding: 20px;
126
  background-color: #fff;
127
  border-radius: 12px;
128
  border: 2px solid #fdf4e3;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
  .bill-details {
131
  display: grid;
 
151
  grid-template-columns: 1fr 1fr;
152
  font-weight: 600;
153
  font-size: 1.2rem;
 
 
 
 
 
154
  }
155
  .total-bill .amount {
156
  text-align: right;
 
157
  color: #2e7d32;
158
  }
159
+ .checkout-button {
160
+ background-color: #A52A2A;
161
+ color: #ffffff;
162
+ padding: 12px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  border-radius: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  border: none;
165
+ width: 100%;
166
  font-size: 1rem;
 
167
  cursor: pointer;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  margin-top: 15px;
169
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  </style>
171
  </head>
172
  <body>
 
173
  <div class="top-bar">
174
  <a href="/menu" class="back-link">
175
  <span class="back-arrow">⟨</span>
 
177
  </a>
178
  </div>
179
 
 
180
  <div class="order-heading">Your Cart</div>
181
 
182
  <div class="container">
183
  <div class="cart-container">
184
+ {% for item in cart_items %}
185
+ <div class="cart-item">
186
+ <div class="image-wrapper">
187
+ <img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
188
+ </div>
189
+ <div class="cart-item-details">
190
+ <div class="cart-item-title">{{ item.Name }}</div>
191
+ <div class="cart-item-addons">
192
+ <small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
193
  </div>
194
+ <div class="cart-item-instructions">
195
+ <small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
 
 
 
 
 
 
 
 
 
 
 
196
  </div>
197
+ <div class="cart-item-quantity mt-2">
198
+ <button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
199
+ <input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
200
+ <button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
 
201
  </div>
202
  </div>
203
+ <div class="cart-item-actions">
204
+ <button type="button" class="remove-btn" onclick="removeItemFromCart('{{ item.Name }}')">
205
+ <i class="bi bi-trash"></i>
206
+ </button>
207
+ <div class="text-primary">${{ item.Price__c }}</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  </div>
209
  </div>
210
+ {% else %}
211
+ <p>No items in your cart.</p>
212
+ {% endfor %}
213
 
 
214
  <div class="cart-summary">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  <div class="bill-details">
216
  <div class="label">Subtotal</div>
217
+ <div class="amount">${{ subtotal }}</div>
 
 
218
  </div>
219
  <div class="dotted-line"></div>
220
  <div class="total-bill">
221
  <div class="label">Total</div>
222
+ <div class="amount">${{ subtotal }}</div>
223
  </div>
224
+ <button class="checkout-button" onclick="proceedToBill()">Generate Bill</button>
 
 
 
225
  </div>
226
  </div>
227
  </div>
228
 
229
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  function updateQuantity(action, itemName, customerEmail) {
231
  let quantityInput = document.querySelector(`input[data-item-name="${itemName}"]`);
232
  let quantity = parseInt(quantityInput.value);
 
248
  .then(data => {
249
  if (data.success) {
250
  quantityInput.value = quantity;
 
 
 
 
 
 
 
251
  location.reload();
252
  } else {
253
  alert("Error updating quantity: " + data.error);
 
256
  .catch(err => console.error("Error:", err));
257
  }
258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  function removeItemFromCart(itemName) {
260
  fetch(`/cart/remove/${encodeURIComponent(itemName)}`, {
261
  method: 'POST',
 
273
  .catch(err => console.error('Error removing item:', err));
274
  }
275
 
276
+ function proceedToBill() {
277
+ window.location.href = '/bill';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  }
279
  </script>
280
  </body>