lokeshloki143 commited on
Commit
9a5f1c7
·
verified ·
1 Parent(s): 0225d47

Update templates/cart.html

Browse files
Files changed (1) hide show
  1. templates/cart.html +436 -641
templates/cart.html CHANGED
@@ -7,487 +7,406 @@
7
  <!-- Bootstrap CSS -->
8
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
9
  <style>
10
-
11
  body {
12
  font-family: Arial, sans-serif;
13
- background-color: #fdf4e3; /* Updated background color */
14
- color: #333;
15
- }
16
- /* Top orange bar */
17
- .top-bar {
18
- background-color: #FF6F3C;
19
- width: 100%;
20
- padding: 10px 15px;
21
- display: flex;
22
- align-items: center;
23
- box-sizing: border-box;
24
- }
25
- .back-link {
26
- display: flex;
27
- align-items: center;
28
- text-decoration: none;
29
- }
30
- .back-arrow {
31
- font-size: 1.8rem;
32
- color: #000; /* Dark black */
33
- font-weight: bold;
34
- }
35
- .back-label {
36
- margin-left: 10px;
37
- color: white;
38
- font-weight: bold;
39
- font-size: 1rem;
40
- }
41
- h1 {
42
- color: #1C1C1C;
43
- font-size: 1.2rem;
44
- margin: 30px 0 15px; /* Default margin for larger screens */
45
- text-align: center;
46
- }
47
- /* Title Styling: Dark Black, Centered, and Larger Size */
48
- .order-heading {
49
- color: #000; /* Dark black color */
50
- font-size: 2.5rem; /* Larger font size for desktop */
51
- font-weight: bold;
52
- text-align: center;
53
- margin-top: 30px; /* Spacing from the top */
54
- }
55
- .cart-container {
56
- max-width: 768px;
57
- margin: 20px auto;
58
- padding: 15px;
59
- background-color: #FFFFFF;
60
- border-radius: 10px;
61
-
62
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
63
- }
64
- .cart-container2 {
65
- background-color:#FFFFFF;
66
  display: flex;
67
- flex-direction: column;
68
- padding: 10px;
69
-
70
-
71
- }
72
- .cart-item {
73
- display: flex;
74
- align-items: flex-start;
75
- justify-content: space-between;
76
- border: 1px solid transparent; /* Set the border to transparent */
77
- padding: 30px 15px 15px;
78
- background-color: #fff; /* Padding for the content */
79
- box-sizing: border-box;
80
- min-height: 100px;
81
- position: relative; /* Make the cart item a reference for the absolute positioning of the remove icon */
82
- border: 1px solid #fdf4e3; /* light Orange border around each item */
83
- border-radius: 8px; /* Rounded corners for items */
84
- }
85
-
86
- .remove-btn {
87
- border: none; /* Remove the border around the button */
88
- background-color: transparent; /* Transparent background */
89
- cursor: pointer; /* Change cursor to pointer */
90
- font-size: 1.2rem; /* Slightly decrease the size of the trash icon */
91
- margin-bottom: 10px; /* Add space below the delete icon */
92
- transition: color 0.3s ease; /* Smooth transition for icon color */
93
- position: relative; /* Make it relative for movement */
94
- top: -35px; /* Move the button 10px upwards */
95
- left: 50px; /* Move the button 30px to the right */
96
- }
97
- .remove-btn i {
98
- color: red; /* Make the trash icon red */
99
- }
100
- /* Hover effect */
101
- .remove-btn:hover {
102
- color: black; /* Change the icon color to black on hover */
103
- background-color: transparent; /* Keep background transparent on hover */
104
- }
105
- /* Prevent background color on focus or click */
106
- .remove-btn:focus {
107
- outline: none; /* Remove the outline */
108
- background-color: transparent; /* Keep background transparent after clicking */
109
- }
110
-
111
- /* Green Color for Prices */
112
- .text-primary {
113
- color: #2e7d32; /* Green color for the prices */
114
- text-align: right; /* Center-align the price */
115
- font-weight: bold; /* Make the price text bold */
116
- white-space: nowrap; /* Prevent price text from wrapping */
117
- }
118
- /* For the image container */
119
- .image-wrapper {
120
- width: 80px; /* Width of the image container */
121
- height: 80px !important; /* Set the height of the container to match the image */
122
- display: flex; /* Flex container for the image */
123
- align-items: center; /* Center image vertically */
124
- justify-content: center; /* Center image horizontally */
125
- }
126
- /* For the image */
127
- .cart-item img {
128
- width: 70px; /* Set the width to 70px */
129
- height: 70px; /* Set the height to 70px */
130
- object-fit: cover; /* Ensure the image covers the container without stretching */
131
- border-radius: 5px; /* Optional: rounded corners */
132
- border: 1px solid #ffcc80; /* Light orange border around images */
133
- margin: 0; /* Ensure no extra space around the image */
134
- }
135
-
136
- .cart-item img:hover {
137
- transform: scale(1.05);
138
- }
139
- .cart-item-title {
140
- font-size: 1.1rem;
141
- font-weight: bold; /* Make the title text bold */
142
- }
143
-
144
- .checkout-button {
145
- background-color: #A52A2A;
146
- color: #ffffff; /* White text */
147
- padding: 12px;
148
- border-radius: 8px;
149
- border: none;
150
- width: 100%;
151
- font-size: 1rem;
152
- cursor: pointer;
153
- transition: background-color 0.3s, color 0.3s;
154
- }
155
- .checkout-button:hover {
156
- background-color: #A52A2A;
157
- color: #ffffff; /* White text on hover */
158
- }
159
- .add-back-button {
160
- padding: 6px 20px;
161
- font-size: 0.9rem;
162
- border-radius: 20px;
163
- border: 1px solid #fff;
164
- background-color: #fff;
165
- color: #0FAA39;
166
- cursor: pointer;
167
- transition: background-color 0.3s, color 0.3s;
168
- }
169
- .add-back-button:hover {
170
- background-color: #fff;
171
- color: #0FAA39;
172
- }
173
-
174
- .cart-item-details {
175
- flex: 1;
176
- margin-left: 15px;
177
- }
178
-
179
- .cart-item-quantity {
180
- display: flex;
181
- align-items: center;
182
- margin-top: 5px;
183
- }
184
- .cart-item-quantity button {
185
- width: 24px;
186
- height: 24px;
187
- border: none;
188
- background-color: #f0f0f0;
189
- font-size: 0.8rem;
190
- font-weight: bold;
191
- cursor: pointer;
192
- }
193
- .cart-item-quantity input {
194
- width: 40px;
195
- text-align: center;
196
- border: none;
197
- background-color: #f8f9fa;
198
- font-size: 1rem;
199
- margin: 0 5px;
200
- }
201
- /* Make the parent container position relative */
202
- .cart-summary {
203
- position: relative; /* Make sure dropdown is positioned relative to this container */
204
- text-align: left;
205
- margin-top: 15px;
206
- padding: 20px;
207
- background-color: #fff;
208
- border-radius: 12px;
209
- border: 2px solid #fdf4e3; /* light Orange border around the cart summary */
210
- box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
211
- }
212
- .cart-item-instructions {
213
- word-wrap: break-word; /* Ensure that long instructions text wraps to the next line */
214
- white-space: normal; /* Allow text to wrap and prevent overflow */
215
- overflow: hidden; /* Hide any overflow text */
216
- max-width: 100%; /* Ensure instructions text stays within the container's width */
217
- word-break: break-word; /* Break the word when necessary */
218
-
219
- }
220
- /* Coupon Section styling */
221
- .coupon-selection {
222
- display: flex; /* Use flexbox to align items */
223
- justify-content: space-between; /* Space between the label and the link */
224
- align-items: center;
225
- font-size: 1rem;
226
- margin-bottom: 20px; /* Add space below Apply Coupon section */
227
- position: relative; /* Ensure dropdown is within this container */
228
- }
229
- /* Ensure the Apply Coupon label and link are aligned correctly */
230
- .coupon-selection label {
231
- font-weight: bold;
232
- color: black;
233
- }
234
- .coupon-selection a {
235
- color: #007bff; /* Blue for the link */
236
- font-size: 1rem;
237
- text-decoration: none;
238
- text-align: right;
239
- }
240
- /* Coupon Dropdown styling */
241
- #couponDropdown {
242
- width: 30%; /* Set dropdown to 30% of the width */
243
- display: none; /* Hidden by default */
244
- background-color: #fff;
245
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Add shadow */
246
- z-index: 10; /* Ensure it's above other content */
247
- margin-top: 10px; /* Add space from the link */
248
- margin-left: auto; /* Push it to the right side */
249
- margin-right: 0; /* Ensure it doesn't overflow outside */
250
- }
251
- /* Show the dropdown when it's active */
252
- #couponDropdown.show {
253
- display: block;
254
- }
255
- /* Ensure Apply Coupon section aligns correctly */
256
- .coupon-selection {
257
- display: flex;
258
- justify-content: space-between;
259
- align-items: center;
260
- font-size: 1rem;
261
- margin-bottom: 20px; /* Add space below Apply Coupon section */
262
- }
263
- /* Apply Coupon link and label styles */
264
- .coupon-selection label {
265
- font-weight: bold;
266
- color: black;
267
- }
268
- .coupon-selection a {
269
- color: #007bff; /* Blue for the link */
270
- font-size: 1rem;
271
- text-decoration: none;
272
- text-align: right;
273
- }
274
- /* Bill details grid structure */
275
- .bill-details {
276
- display: grid;
277
- grid-template-columns: 1fr 1fr; /* Two-column layout */
278
- grid-gap: 10px;
279
- margin-bottom: 10px;
280
- }
281
- /* Adjust label and amount for bill details */
282
- .bill-details .label {
283
- font-weight: 600;
284
- font-size: 1rem;
285
- }
286
- .bill-details .amount {
287
- text-align: right;
288
- font-weight: 600;
289
- font-size: 1rem;
290
- }
291
- /* Divider line between bill sections */
292
- .dotted-line {
293
- border-bottom: 2px dotted #ccc;
294
- margin: 15px 0;
295
- }
296
- /* Total bill grid layout */
297
- .total-bill {
298
- display: grid;
299
- grid-template-columns: 1fr 1fr;
300
- font-weight: 600;
301
- font-size: 1.2rem;
302
- margin-top: 10px;
303
- margin-bottom: 10px; /* Add 10px space between To Pay and Submit Button */
304
- }
305
- .total-bill .label {
306
- font-size: 1.1rem;
307
- }
308
- .total-bill .amount {
309
- text-align: right;
310
- font-size: 1.1rem;
311
- color: #2e7d32; /* Green for Total Bill Price */
312
- }
313
- /* Margin to add space for dropdown when visible */
314
- .cart-summary.has-dropdown {
315
- margin-bottom: 80px; /* Create space below the content when dropdown is visible */
316
- }
317
- .checkout-button {
318
- background-color: #A52A2A;
319
- color: #ffffff;
320
- padding: 12px;
321
- border-radius: 8px;
322
- border: none;
323
- height: 44px;
324
- width: 100%;
325
- font-size: 1rem;
326
- cursor: pointer;
327
- transition: background-color 0.3s, color 0.3s;
328
- display: flex;
329
- justify-content: center;
330
- align-items: center;
331
- text-align: center;
332
- }
333
- .suggestion-section {
334
- margin-top: 25px;
335
- padding: 15px;
336
- background-color: #fff;
337
- border-radius: 10px;
338
- border: 2px solid #fdf4e3; /* light Orange border around the complete meal box */
339
- }
340
- .suggestion-items-container {
341
- display: flex;
342
- overflow-x: auto; /* Horizontal scrolling */
343
- gap: 10px; /* Space between items */
344
- padding-bottom: 10px;
345
- padding-top: 10px;
346
- }
347
- /* Styling for the suggestion item card */
348
- .suggestion-item {
349
- display: flex; /* Align items horizontally */
350
- align-items: center; /* Center image and text vertically */
351
- justify-content: flex-start; /* Align items to the start (left side) */
352
- flex-shrink: 0;
353
- width: 160px; /* Set fixed width for each suggestion item */
354
- padding: 10px;
355
- border-radius: 8px; /* Rounded corners */
356
- background-color: #fff;
357
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
358
- transition: transform 0.3s ease;
359
- margin-right: 10px; /* Ensure there's space between the cards */
360
- position: relative; /* For positioning the + icon */
361
- text-align: left; /* Align text to the left */
362
- overflow: visible; /* Allow the button to overflow outside */
363
- border: 2px solid #fdf4e3; /* light Orange border around the suggestion items */
364
- }
365
- .suggestion-item:hover {
366
- transform: scale(1.05); /* Slight zoom effect on hover */
367
- }
368
- .suggestion-item img {
369
- width: 50px; /* Set a fixed width for the image */
370
- height: 50px; /* Set a fixed height for the image */
371
- object-fit: cover; /* Ensure image fits correctly without distortion */
372
- border-radius: 5px; /* Rounded corners for the image */
373
- margin-right: 12px; /* Space between the image and text */
374
- }
375
- .suggestion-item div {
376
- flex-grow: 1; /* Allow the text section to expand and fill available space */
377
- text-align: left; /* Align text to the left */
378
- }
379
- /* Styling for the + symbol button (with green border, white background, and black text) */
380
- .add-back-button {
381
- position: absolute;
382
- top: -5px;
383
- right: -10px;
384
- font-size: 1rem; /* Smaller font size */
385
- padding: 0; /* Remove padding */
386
- width: 30px; /* Set fixed width */
387
- height: 30px; /* Set fixed height */
388
- background-color: #fff;
389
- color: #0FAA39;
390
- border: 2px solid #0FAA39;
391
- border-radius: 0; /* Square shape */
392
- cursor: pointer;
393
- transition: background-color 0.3s, color 0.3s, border-color 0.3s;
394
- z-index: 2; /* Increased z-index to ensure it stays above the borders */
395
- }
396
- .add-back-button:hover {
397
- background-color: #fff; /* Green background on hover */
398
- color: #0FAA39; /* White color for the + symbol when hovered */
399
- border-color: #0FAA39; /* Green border on hover */
400
- z-index: 3; /* Ensure button stays on top when hovered */
401
- }
402
- /* Ensure the scroll container works fine */
403
- .suggestion-items-container::-webkit-scrollbar {
404
- height: 8px; /* Height of the scrollbar */
405
- }
406
- .suggestion-items-container::-webkit-scrollbar-thumb {
407
- background-color: #fff; /* Green color for scrollbar thumb */
408
- border-radius: 4px;
409
- }
410
- .suggestion-items-container::-webkit-scrollbar-track {
411
- background-color: #f1f1f1;
412
- }
413
-
414
- .cart-item-actions {
415
- display: flex; /* Use flexbox to align items horizontally */
416
- align-items: flex-start; /* Align the price at the top of the cart item (like the item name) */
417
- margin-left: auto; /* This will push the price to the right side of the cart item */
418
- }
419
- h4.mb-4.fw-bold {
420
- text-align: center; /* Centers the title */
421
- color: #FF5722; /* Orange color for the title */
422
- .cart-container h4 {
423
- text-align: center; /* This will center the title horizontally */
424
- color: #FF5722; /* Orange color */
425
- font-weight: bold; /* Make it bold */
426
- }
427
-
428
-
429
- <body>
430
  </style>
431
  </head>
432
- <!-- Top Orange Label Bar -->
433
- <div class="top-bar">
434
- <a href="/menu" class="back-link">
435
- <span class="back-arrow">&#10216;</span>
436
- <span class="back-label">Back to Menu</span>
437
- </a>
438
- </div>
439
- <!-- Order History Title (centered and dark black) -->
440
- <div class="order-heading">Your Cart</div>
441
-
442
-
443
  <div class="container">
444
  <div class="cart-container">
445
- <div style="text-align: right;">
446
- </div>
447
-
448
-
449
- <div class="cart-container2">
450
- {% for item in cart_items %}
451
- <div class="cart-item">
452
- <div class="image-wrapper">
453
- <img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
454
- </div>
455
- <div class="cart-item-details">
456
- <div class="cart-item-title">
457
- {{ item.Name }}
458
- </div>
459
- <div class="cart-item-addons">
460
- <small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
461
- </div>
462
- <div class="cart-item-instructions">
463
- <small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
464
- </div>
465
- <div class="cart-item-quantity mt-2">
466
- <button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
467
- <input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
468
- <button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
469
- </div>
470
- </div>
471
- <div class="cart-item-actions">
472
- <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
473
-
474
- <!-- Delete Button with Trash Icon and onclick handler -->
475
- <button type="button" class="btn btn-light text-dark remove-btn" onclick="removeItemFromCart('{{ item.Name }}')">
476
- <i class="bi bi-trash"></i>
477
- </button>
478
-
479
- <div class="text-primary" style="color: #000 !important;">
480
- $<span class="base-price">{{ item.Price__c }}</span>
481
- </div>
482
  </div>
483
  </div>
 
484
  {% else %}
485
- <!-- Code to handle the case when cart_items is empty -->
486
- <p>No items in your cart.</p>
487
  {% endfor %}
488
  </div>
489
-
490
-
491
  <!-- Suggestions Section -->
492
  {% if suggestions %}
493
  <div class="suggestion-section">
@@ -500,79 +419,55 @@
500
  <div>{{ suggestion.Name }}</div>
501
  <div class="text-muted">${{ suggestion.Price__c }}</div>
502
  </div>
503
- <!-- Replace add button with a cart icon -->
504
  <button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}', '{{ suggestion.Id }}')">+</button>
505
-
506
-
507
  </div>
508
  {% endfor %}
509
  </div>
510
  </div>
511
-
512
  {% endif %}
513
-
514
  <!-- Subtotal -->
515
  <div class="cart-summary">
516
- <!-- Coupon Section -->
517
- {% if coupons %}
518
- <div class="coupon-selection d-flex justify-content-between align-items-center">
519
- <label class="text-dark font-weight-bold mb-0">Apply Coupon</label>
520
- <a href="javascript:void(0);" id="applyCouponLink" onclick="toggleCouponDropdown()" class="text-primary">+ Apply Coupon</a>
521
- </div>
522
-
523
- <!-- Coupon Dropdown, positioned below Apply Coupon -->
524
- <select id="couponDropdown" class="form-select mt-2" style="display:none;" onchange="calculateDiscount()">
525
- <option value="">Select a coupon</option>
526
- {% for coupon in coupons %}
527
- <option value="{{ coupon }}">{{ coupon }}</option>
528
- {% endfor %}
529
- </select>
530
- {% endif %}
531
-
532
-
533
-
534
  <div class="bill-details">
535
  <div class="label">Cart Total</div>
536
  <div class="amount">${{ subtotal }}</div>
537
-
538
-
539
  <div class="label">Discount</div>
540
  <div class="amount" id="discountText">-${{ discount }}</div>
541
-
542
-
543
-
544
-
545
  </div>
546
-
547
  <div class="dotted-line"></div>
548
-
549
  <div class="total-bill">
550
- <div class="label">To Pay</div>
551
- <div class="amount" id="totalBillText">${{ subtotal }}</div>
552
  </div>
553
  <button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
554
  </div>
555
  </div>
556
  </div>
557
-
558
-
559
  <script>
560
- // Example function to handle the increase/decrease button clicks
561
  function updateQuantity(action, itemName, customerEmail) {
562
  let quantityInput = document.querySelector(`input[data-item-name="${itemName}"]`);
563
  let quantity = parseInt(quantityInput.value);
564
- // Update quantity based on action
565
  if (action === 'increase') {
566
  quantity++;
567
  } else if (action === 'decrease' && quantity > 1) {
568
  quantity--;
569
  }
570
- // Validate quantity
571
  if (isNaN(quantity) || quantity < 1) {
572
  alert("Invalid quantity!");
573
  return;
574
  }
575
- // Send updated quantity to the server
576
  fetch('/cart/update_quantity', {
577
  method: 'POST',
578
  headers: { 'Content-Type': 'application/json' },
@@ -581,217 +476,117 @@
581
  .then(response => response.json())
582
  .then(data => {
583
  if (data.success) {
584
- // Update the item price and quantity in the UI
585
  quantityInput.value = quantity;
586
- let itemElement = quantityInput.closest(".cart-item"); // Locate the parent cart item
587
  if (itemElement) {
588
  let basePriceElement = itemElement.querySelector(".base-price");
589
- let addonsPriceElement = itemElement.querySelector(".addons-price");
590
- // Update the base price
591
  if (basePriceElement) {
592
- basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
593
- }
594
- // Update add-ons price if needed (optional)
595
- if (addonsPriceElement && data.addons_price !== undefined) {
596
- addonsPriceElement.innerText = data.addons_price.toFixed(2);
597
  }
598
- } else {
599
- console.error(`Parent cart item element not found for item: ${itemName}`);
600
  }
601
  location.reload();
602
- // Recalculate subtotal dynamically
603
-
604
  } else {
605
  alert("Error updating quantity: " + data.error);
606
  }
607
  })
608
  .catch(err => console.error("Error:", err));
609
  }
 
610
  function toggleCouponDropdown() {
611
  let couponDropdown = document.getElementById('couponDropdown');
612
-
613
- // Toggle the visibility of the coupon dropdown
614
- if (couponDropdown.style.display === "none" || couponDropdown.style.display === "") {
615
- couponDropdown.style.display = "block";
616
- } else {
617
- couponDropdown.style.display = "none";
618
- }
619
  }
 
620
  function calculateDiscount() {
621
- let couponDropdown = document.getElementById('couponDropdown'); // Get coupon dropdown
622
- let selectedCoupon = couponDropdown.value.trim(); // Get the selected coupon value
623
- let subtotal = parseFloat("{{ subtotal }}"); // Get the subtotal (from the backend)
624
- // If a valid coupon is selected
625
  if (selectedCoupon && selectedCoupon.toLowerCase() !== "none") {
626
- // Apply 10% discount
627
  let discount = subtotal * 0.10;
628
  let total = subtotal - discount;
629
- // Update UI with discount and total bill
630
  document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
631
  document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
632
  } else {
633
- // If no coupon is selected or "None" is selected, reset the discount
634
  document.getElementById("discountText").innerText = `$0.00`;
635
  document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
636
  }
637
  }
638
-
639
  function proceedToOrder() {
640
  let couponDropdown = document.getElementById('couponDropdown');
641
-
642
- // Initialize selectedCoupon to an empty string by default
643
- let selectedCoupon = "";
644
-
645
- // Only proceed if couponDropdown exists
646
- if (couponDropdown) {
647
- // If the value is not null or undefined, strip the value
648
- if (couponDropdown.value != null) {
649
- selectedCoupon = couponDropdown.value.trim(); // safely call .trim() if value is not null
650
- } else {
651
- selectedCoupon = ""; // Assign empty string if value is null
652
- }
653
- }
654
- // If no coupon is selected or the value is empty, treat it as no coupon
655
- if (selectedCoupon === "" || selectedCoupon === "None" || selectedCoupon === "Null") {
656
- selectedCoupon = null; // Treat it as no coupon selected
657
  }
658
- // Send the selected coupon to the backend for processing
659
  fetch('/checkout', {
660
  method: 'POST',
661
  headers: { 'Content-Type': 'application/json' },
662
  body: JSON.stringify({ selectedCoupon: selectedCoupon })
663
  })
664
- .then(response => response.json())
665
- .then(data => {
666
- if (data.success) {
667
- alert(data.message); // Success message
668
- window.location.href = '/order'; // Redirect to order page
669
- } else {
670
- alert(data.error || data.message); // Handle error message
671
  }
 
672
  })
673
- .catch(err => console.error('Error during checkout:', err));
674
- }
675
- function calculateSubtotal() {
676
- let subtotal = 0;
677
- document.querySelectorAll('.cart-item').forEach(item => {
678
- const quantity = parseInt(item.querySelector('input').value);
679
- const basePrice = parseFloat(item.querySelector('.base-price').innerText.replace('$', '')); // Base Price
680
- const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
681
- subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
682
- });
683
- // Update the subtotal in the HTML
684
- document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
685
- return subtotal;
686
- }
687
- function addSuggestion(itemId) {
688
- fetch(`/cart/add_suggestion/${itemId}`, {
689
- method: 'POST',
690
- headers: { 'Content-Type': 'application/json' },
691
- body: JSON.stringify({})
692
- })
693
- .then(response => response.json())
694
  .then(data => {
695
  if (data.success) {
696
- alert('Item added to cart!');
697
- location.reload();
698
  } else {
699
- alert(data.error);
700
  }
701
  })
702
- .catch(err => console.error('Error adding suggestion:', err));
 
 
 
703
  }
 
704
  function removeItemFromCart(itemName) {
705
  fetch(`/cart/remove/${encodeURIComponent(itemName)}`, {
706
  method: 'POST',
707
- headers: {
708
- 'Content-Type': 'application/json'
709
- }
710
  })
711
  .then(response => response.json())
712
  .then(data => {
713
  if (data.success) {
714
  alert(data.message);
715
- location.reload(); // Reload the page to update the cart
716
  } else {
717
  alert(data.message);
718
  }
719
  })
720
  .catch(err => console.error('Error removing item:', err));
721
  }
722
- function addToCart(itemName, customerEmail) {
723
- fetch(`/cart/add_item`, {
724
- method: "POST",
725
- headers: { "Content-Type": "application/json" },
726
- body: JSON.stringify({
727
- email: customerEmail,
728
- item_name: itemName.trim(), //Ensure the item name is trimmed
729
- quantity: 0 // DEFAULT QUANTITY PASSED HERE
730
- })
731
- })
732
- .then(response => response.json())
733
- .then(data => {
734
- if (data.success) {
735
- alert("Item added/updated successfully.");
736
- location.reload(); // Reload the page to update the cart
737
- } else {
738
- alert(data.error || "Failed to add item to cart.");
739
- }
740
- })
741
- .catch(err => console.error("Error adding item to cart:", err));
742
- }
743
- function addSuggestion(itemId) {
744
- fetch(`/cart/add_suggestion/${itemId}`, {
745
- method: 'POST',
746
- headers: { 'Content-Type': 'application/json' },
747
- body: JSON.stringify({})
748
- })
749
- .then(response => response.json())
750
- .then(data => {
751
- if (data.success) {
752
- alert('Item added to cart!');
753
- location.reload();
754
- } else {
755
- alert(data.error);
756
- }
757
- })
758
- .catch(err => console.error('Error adding suggestion:', err));
759
- }
760
  function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
761
- const customerEmail = "{{ customer_email }}"; // Get customer email from session
762
- // Create the data object to send to the ser ver
763
  const data = {
764
  item_name: itemName,
765
  item_price: itemPrice,
766
  item_image: itemImage,
767
  item_id: itemId,
768
- addons: [], // Default to empty, you can adjust if needed
769
- instructions: "", // Default to empty, you can adjust if needed
770
  customer_email: customerEmail
771
  };
772
- // Send the data to the backend via a POST request
773
  fetch('/cart/add_suggestion_to_cart', {
774
  method: 'POST',
775
- headers: {
776
- 'Content-Type': 'application/json'
777
- },
778
  body: JSON.stringify(data)
779
  })
780
  .then(response => response.json())
781
  .then(data => {
782
  if (data.success) {
783
  alert('Item added to cart!');
784
- location.reload(); // Reload to update the cart view
785
  } else {
786
  alert('Error adding item to cart: ' + data.error);
787
  }
788
  })
789
  .catch(err => console.error('Error adding item:', err));
790
  }
791
-
792
-
793
  </script>
794
-
795
  </body>
796
- </html>
797
-
 
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>
364
+ <!-- Top Orange Label Bar -->
365
+ <div class="top-bar">
366
+ <a href="/menu" class="back-link">
367
+ <span class="back-arrow">⟨</span>
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">
 
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>
452
  </div>
453
  <button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
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);
 
462
  if (action === 'increase') {
463
  quantity++;
464
  } else if (action === 'decrease' && quantity > 1) {
465
  quantity--;
466
  }
 
467
  if (isNaN(quantity) || quantity < 1) {
468
  alert("Invalid quantity!");
469
  return;
470
  }
 
471
  fetch('/cart/update_quantity', {
472
  method: 'POST',
473
  headers: { 'Content-Type': 'application/json' },
 
476
  .then(response => response.json())
477
  .then(data => {
478
  if (data.success) {
 
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();
 
 
488
  } else {
489
  alert("Error updating quantity: " + data.error);
490
  }
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();
503
+ let subtotal = parseFloat("{{ subtotal }}");
 
504
  if (selectedCoupon && selectedCoupon.toLowerCase() !== "none") {
 
505
  let discount = subtotal * 0.10;
506
  let total = subtotal - discount;
 
507
  document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
508
  document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
509
  } else {
 
510
  document.getElementById("discountText").innerText = `$0.00`;
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',
549
+ headers: { 'Content-Type': 'application/json' }
 
 
550
  })
551
  .then(response => response.json())
552
  .then(data => {
553
  if (data.success) {
554
  alert(data.message);
555
+ location.reload();
556
  } else {
557
  alert(data.message);
558
  }
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 = {
566
  item_name: itemName,
567
  item_price: itemPrice,
568
  item_image: itemImage,
569
  item_id: itemId,
570
+ addons: [],
571
+ instructions: "",
572
  customer_email: customerEmail
573
  };
 
574
  fetch('/cart/add_suggestion_to_cart', {
575
  method: 'POST',
576
+ headers: { 'Content-Type': 'application/json' },
 
 
577
  body: JSON.stringify(data)
578
  })
579
  .then(response => response.json())
580
  .then(data => {
581
  if (data.success) {
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));
589
  }
 
 
590
  </script>
 
591
  </body>
592
+ </html>