nagasurendra commited on
Commit
b818637
·
verified ·
1 Parent(s): bb447e5

Update templates/cart.html

Browse files
Files changed (1) hide show
  1. templates/cart.html +100 -119
templates/cart.html CHANGED
@@ -10,39 +10,23 @@
10
 
11
  body {
12
  font-family: Arial, sans-serif;
13
- background-color: #fdf4e3; /* Updated background color */
14
  color: #333;
15
  }
16
  .cart-container {
17
  max-width: 768px;
18
  margin: 20px auto;
19
  padding: 15px;
20
- background-color: #FFFFFF;
21
  border-radius: 10px;
22
-
23
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
24
  }
25
  .cart-container2 {
26
- background-color:#FFFFFF;
27
  }
28
- /* Green Back Button styling */
29
- .back-button {
30
- position: absolute;
31
- top: 15px;
32
- left: 15px;
33
- display: inline-block;
34
- background-color: green; /* Green color */
35
- color: white;
36
- padding: 10px 20px;
37
- text-decoration: none;
38
- font-weight: bold;
39
- border-radius: 4px;
40
- z-index: 10; /* Ensure it stays above other content */
41
- }
42
- .back-button:hover {
43
- background-color: darkgreen; /* Darker green color on hover */
44
- }
45
- .cart-item {
46
  display: flex;
47
  align-items: flex-start;
48
  justify-content: space-between;
@@ -52,23 +36,19 @@
52
  box-sizing: border-box;
53
  min-height: 100px;
54
  position: relative; /* Make the cart item a reference for the absolute positioning of the remove icon */
55
- border: 1px solid #fdf4e3; /* light Orange border around each item */
56
- border-radius: 8px; /* Rounded corners for items */
57
  }
 
58
  .remove-btn {
59
  border: none; /* Remove the border around the button */
60
  background-color: transparent; /* Transparent background */
61
  cursor: pointer; /* Change cursor to pointer */
62
- font-size: 1.2rem; /* Slightly decrease the size of the trash icon */
63
  margin-bottom: 10px; /* Add space below the delete icon */
64
  transition: color 0.3s ease; /* Smooth transition for icon color */
65
  position: relative; /* Make it relative for movement */
66
- top: -35px; /* Move the button 10px upwards */
67
  left: 50px; /* Move the button 30px to the right */
68
  }
69
- .remove-btn i {
70
- color: red; /* Make the trash icon red */
71
- }
72
  /* Hover effect */
73
  .remove-btn:hover {
74
  color: black; /* Change the icon color to black on hover */
@@ -79,53 +59,53 @@
79
  outline: none; /* Remove the outline */
80
  background-color: transparent; /* Keep background transparent after clicking */
81
  }
82
- /* Green Color for Prices */
83
  .text-primary {
84
- color: #2e7d32; /* Green color for the prices */
85
  text-align: right; /* Center-align the price */
86
- font-weight: bold; /* Make the price text bold */
87
  white-space: nowrap; /* Prevent price text from wrapping */
88
  }
89
- /* For the image container */
90
  .image-wrapper {
91
  width: 80px; /* Width of the image container */
92
- height: 80px !important; /* Set the height of the container to match the image */
93
- display: flex; /* Flex container for the image */
94
- align-items: center; /* Center image vertically */
95
- justify-content: center; /* Center image horizontally */
96
- }
97
- /* For the image */
98
- .cart-item img {
99
- width: 70px; /* Set the width to 70px */
100
- height: 70px; /* Set the height to 70px */
101
- object-fit: cover; /* Ensure the image covers the container without stretching */
102
- border-radius: 5px; /* Optional: rounded corners */
103
- border: 1px solid #ffcc80; /* Light orange border around images */
104
- margin: 0; /* Ensure no extra space around the image */
105
  }
106
-
 
 
 
 
 
 
 
 
 
 
 
107
  .cart-item img:hover {
108
  transform: scale(1.05);
109
  }
110
  .cart-item-title {
111
  font-size: 1.1rem;
112
- font-weight: bold; /* Make the title text bold */
113
  }
114
 
115
  .checkout-button {
116
- background-color: #ff5722; /* Full Orange color */
117
- color: #ffffff; /* White text */
118
- padding: 12px;
119
- border-radius: 8px;
120
- border: none;
121
- width: 100%;
122
- font-size: 1.2rem;
123
- cursor: pointer;
124
- transition: background-color 0.3s, color 0.3s;
125
- }
126
- .checkout-button:hover {
127
- background-color: #ff5722; /* Full Orange color on hover */
128
- color: #ffffff; /* White text on hover */
129
  }
130
  .add-back-button {
131
  padding: 6px 20px;
@@ -177,16 +157,7 @@
177
  padding: 20px;
178
  background-color: #fff;
179
  border-radius: 12px;
180
- border: 2px solid #fdf4e3; /* light Orange border around the cart summary */
181
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
182
- }
183
- .cart-item-instructions {
184
- word-wrap: break-word; /* Ensure that long instructions text wraps to the next line */
185
- white-space: normal; /* Allow text to wrap and prevent overflow */
186
- overflow: hidden; /* Hide any overflow text */
187
- max-width: 100%; /* Ensure instructions text stays within the container's width */
188
- word-break: break-word; /* Break the word when necessary */
189
-
190
  }
191
  /* Coupon Section styling */
192
  .coupon-selection {
@@ -279,15 +250,15 @@
279
  .total-bill .amount {
280
  text-align: right;
281
  font-size: 1.1rem;
282
- color: #2e7d32; /* Green for Total Bill Price */
283
  }
284
  /* Margin to add space for dropdown when visible */
285
  .cart-summary.has-dropdown {
286
  margin-bottom: 80px; /* Create space below the content when dropdown is visible */
287
  }
288
  .checkout-button {
289
- background-color: #ff5722;
290
- color: #ffffff;
291
  padding: 12px;
292
  border-radius: 8px;
293
  border: none;
@@ -306,7 +277,6 @@
306
  padding: 15px;
307
  background-color: #fff;
308
  border-radius: 10px;
309
- border: 2px solid #fdf4e3; /* light Orange border around the complete meal box */
310
  }
311
  .suggestion-items-container {
312
  display: flex;
@@ -331,7 +301,6 @@
331
  position: relative; /* For positioning the + icon */
332
  text-align: left; /* Align text to the left */
333
  overflow: visible; /* Allow the button to overflow outside */
334
- border: 2px solid #fdf4e3; /* light Orange border around the suggestion items */
335
  }
336
  .suggestion-item:hover {
337
  transform: scale(1.05); /* Slight zoom effect on hover */
@@ -387,15 +356,7 @@
387
  align-items: flex-start; /* Align the price at the top of the cart item (like the item name) */
388
  margin-left: auto; /* This will push the price to the right side of the cart item */
389
  }
390
- h4.mb-4.fw-bold {
391
- text-align: center; /* Centers the title */
392
- color: #FF5722; /* Orange color for the title */
393
- .cart-container h4 {
394
- text-align: center; /* This will center the title horizontally */
395
- color: #FF5722; /* Orange color */
396
- font-weight: bold; /* Make it bold */
397
- }
398
-
399
  </style>
400
  </head>
401
  <body>
@@ -528,11 +489,13 @@
528
  } else if (action === 'decrease' && quantity > 1) {
529
  quantity--;
530
  }
 
531
  // Validate quantity
532
  if (isNaN(quantity) || quantity < 1) {
533
  alert("Invalid quantity!");
534
  return;
535
  }
 
536
  // Send updated quantity to the server
537
  fetch('/cart/update_quantity', {
538
  method: 'POST',
@@ -548,10 +511,12 @@
548
  if (itemElement) {
549
  let basePriceElement = itemElement.querySelector(".base-price");
550
  let addonsPriceElement = itemElement.querySelector(".addons-price");
 
551
  // Update the base price
552
  if (basePriceElement) {
553
  basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
554
  }
 
555
  // Update add-ons price if needed (optional)
556
  if (addonsPriceElement && data.addons_price !== undefined) {
557
  addonsPriceElement.innerText = data.addons_price.toFixed(2);
@@ -560,6 +525,7 @@
560
  console.error(`Parent cart item element not found for item: ${itemName}`);
561
  }
562
  location.reload();
 
563
  // Recalculate subtotal dynamically
564
 
565
  } else {
@@ -578,15 +544,19 @@
578
  couponDropdown.style.display = "none";
579
  }
580
  }
 
 
581
  function calculateDiscount() {
582
  let couponDropdown = document.getElementById('couponDropdown'); // Get coupon dropdown
583
  let selectedCoupon = couponDropdown.value.trim(); // Get the selected coupon value
584
  let subtotal = parseFloat("{{ subtotal }}"); // Get the subtotal (from the backend)
 
585
  // If a valid coupon is selected
586
  if (selectedCoupon && selectedCoupon.toLowerCase() !== "none") {
587
  // Apply 10% discount
588
  let discount = subtotal * 0.10;
589
  let total = subtotal - discount;
 
590
  // Update UI with discount and total bill
591
  document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
592
  document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
@@ -596,43 +566,51 @@
596
  document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
597
  }
598
  }
 
 
 
599
 
600
  function proceedToOrder() {
601
- let couponDropdown = document.getElementById('couponDropdown');
602
-
603
- // Initialize selectedCoupon to an empty string by default
604
- let selectedCoupon = "";
605
-
606
- // Only proceed if couponDropdown exists
607
- if (couponDropdown) {
608
- // If the value is not null or undefined, strip the value
609
- if (couponDropdown.value != null) {
610
- selectedCoupon = couponDropdown.value.trim(); // safely call .trim() if value is not null
611
- } else {
612
- selectedCoupon = ""; // Assign empty string if value is null
613
- }
614
- }
615
- // If no coupon is selected or the value is empty, treat it as no coupon
616
- if (selectedCoupon === "" || selectedCoupon === "None" || selectedCoupon === "Null") {
617
- selectedCoupon = null; // Treat it as no coupon selected
618
- }
619
- // Send the selected coupon to the backend for processing
620
- fetch('/checkout', {
621
- method: 'POST',
622
- headers: { 'Content-Type': 'application/json' },
623
- body: JSON.stringify({ selectedCoupon: selectedCoupon })
624
- })
625
- .then(response => response.json())
626
- .then(data => {
627
- if (data.success) {
628
- alert(data.message); // Success message
629
- window.location.href = '/order'; // Redirect to order page
630
- } else {
631
- alert(data.error || data.message); // Handle error message
632
- }
633
- })
634
- .catch(err => console.error('Error during checkout:', err));
635
  }
 
 
 
 
 
 
636
  function calculateSubtotal() {
637
  let subtotal = 0;
638
  document.querySelectorAll('.cart-item').forEach(item => {
@@ -641,6 +619,7 @@
641
  const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
642
  subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
643
  });
 
644
  // Update the subtotal in the HTML
645
  document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
646
  return subtotal;
@@ -749,9 +728,11 @@
749
  })
750
  .catch(err => console.error('Error adding item:', err));
751
  }
 
 
752
 
753
 
754
  </script>
755
 
756
  </body>
757
- </html>
 
10
 
11
  body {
12
  font-family: Arial, sans-serif;
13
+ background-color: #f3f4f6;
14
  color: #333;
15
  }
16
  .cart-container {
17
  max-width: 768px;
18
  margin: 20px auto;
19
  padding: 15px;
20
+ background-color: #fdf4e3;
21
  border-radius: 10px;
 
22
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
23
  }
24
  .cart-container2 {
25
+ background-color: #fdf4e3;
26
  }
27
+
28
+
29
+ .cart-item {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  display: flex;
31
  align-items: flex-start;
32
  justify-content: space-between;
 
36
  box-sizing: border-box;
37
  min-height: 100px;
38
  position: relative; /* Make the cart item a reference for the absolute positioning of the remove icon */
 
 
39
  }
40
+
41
  .remove-btn {
42
  border: none; /* Remove the border around the button */
43
  background-color: transparent; /* Transparent background */
44
  cursor: pointer; /* Change cursor to pointer */
45
+ font-size: 1.5rem; /* Adjust the size of the trash icon */
46
  margin-bottom: 10px; /* Add space below the delete icon */
47
  transition: color 0.3s ease; /* Smooth transition for icon color */
48
  position: relative; /* Make it relative for movement */
49
+ top: -40px; /* Move the button 10px upwards */
50
  left: 50px; /* Move the button 30px to the right */
51
  }
 
 
 
52
  /* Hover effect */
53
  .remove-btn:hover {
54
  color: black; /* Change the icon color to black on hover */
 
59
  outline: none; /* Remove the outline */
60
  background-color: transparent; /* Keep background transparent after clicking */
61
  }
 
62
  .text-primary {
63
+ color: #000 !important; /* Ensure the price is black */
64
  text-align: right; /* Center-align the price */
 
65
  white-space: nowrap; /* Prevent price text from wrapping */
66
  }
67
+ /* Default for larger screens like desktops */
68
  .image-wrapper {
69
  width: 80px; /* Width of the image container */
70
+ height: 140px !important; /* Height of the image container */
71
+ display: flex; /* Flex container for the image */
72
+ align-items: flex-start; /* Align the image at the top */
73
+ justify-content: center; /* Center image horizontally if it has space */
 
 
 
 
 
 
 
 
 
74
  }
75
+
76
+ /* Responsive for mobile devices */
77
+
78
+
79
+ .cart-item img {
80
+ width: 100%; /* Fill the image container */
81
+ height: auto !important; /* Maintain aspect ratio */
82
+ object-fit: contain;
83
+ border-radius: 8px; /* Optional: rounded corners */
84
+ transition: transform 0.3s;/* Ensure the full image is visible */
85
+
86
+ }
87
  .cart-item img:hover {
88
  transform: scale(1.05);
89
  }
90
  .cart-item-title {
91
  font-size: 1.1rem;
92
+ font-weight: 400;
93
  }
94
 
95
  .checkout-button {
96
+ background-color: #0FAA39; /* Green background */
97
+ color: #fff; /* White text */
98
+ padding: 12px;
99
+ border-radius: 8px;
100
+ border: none;
101
+ width: 100%;
102
+ font-size: 1.2rem;
103
+ cursor: pointer;
104
+ transition: background-color 0.3s, color 0.3s;
105
+ }
106
+ .checkout-button:hover {
107
+ background-color: #0FAA39; /* Keep the background green on hover */
108
+ color: #fff; /* Keep the text white on hover */
109
  }
110
  .add-back-button {
111
  padding: 6px 20px;
 
157
  padding: 20px;
158
  background-color: #fff;
159
  border-radius: 12px;
 
160
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
 
 
 
 
 
 
 
 
161
  }
162
  /* Coupon Section styling */
163
  .coupon-selection {
 
250
  .total-bill .amount {
251
  text-align: right;
252
  font-size: 1.1rem;
253
+ color: #000; /* Changed from green to black */
254
  }
255
  /* Margin to add space for dropdown when visible */
256
  .cart-summary.has-dropdown {
257
  margin-bottom: 80px; /* Create space below the content when dropdown is visible */
258
  }
259
  .checkout-button {
260
+ background-color: #0FAA39;
261
+ color: #fff;
262
  padding: 12px;
263
  border-radius: 8px;
264
  border: none;
 
277
  padding: 15px;
278
  background-color: #fff;
279
  border-radius: 10px;
 
280
  }
281
  .suggestion-items-container {
282
  display: flex;
 
301
  position: relative; /* For positioning the + icon */
302
  text-align: left; /* Align text to the left */
303
  overflow: visible; /* Allow the button to overflow outside */
 
304
  }
305
  .suggestion-item:hover {
306
  transform: scale(1.05); /* Slight zoom effect on hover */
 
356
  align-items: flex-start; /* Align the price at the top of the cart item (like the item name) */
357
  margin-left: auto; /* This will push the price to the right side of the cart item */
358
  }
359
+
 
 
 
 
 
 
 
 
360
  </style>
361
  </head>
362
  <body>
 
489
  } else if (action === 'decrease' && quantity > 1) {
490
  quantity--;
491
  }
492
+
493
  // Validate quantity
494
  if (isNaN(quantity) || quantity < 1) {
495
  alert("Invalid quantity!");
496
  return;
497
  }
498
+
499
  // Send updated quantity to the server
500
  fetch('/cart/update_quantity', {
501
  method: 'POST',
 
511
  if (itemElement) {
512
  let basePriceElement = itemElement.querySelector(".base-price");
513
  let addonsPriceElement = itemElement.querySelector(".addons-price");
514
+
515
  // Update the base price
516
  if (basePriceElement) {
517
  basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
518
  }
519
+
520
  // Update add-ons price if needed (optional)
521
  if (addonsPriceElement && data.addons_price !== undefined) {
522
  addonsPriceElement.innerText = data.addons_price.toFixed(2);
 
525
  console.error(`Parent cart item element not found for item: ${itemName}`);
526
  }
527
  location.reload();
528
+
529
  // Recalculate subtotal dynamically
530
 
531
  } else {
 
544
  couponDropdown.style.display = "none";
545
  }
546
  }
547
+
548
+
549
  function calculateDiscount() {
550
  let couponDropdown = document.getElementById('couponDropdown'); // Get coupon dropdown
551
  let selectedCoupon = couponDropdown.value.trim(); // Get the selected coupon value
552
  let subtotal = parseFloat("{{ subtotal }}"); // Get the subtotal (from the backend)
553
+
554
  // If a valid coupon is selected
555
  if (selectedCoupon && selectedCoupon.toLowerCase() !== "none") {
556
  // Apply 10% discount
557
  let discount = subtotal * 0.10;
558
  let total = subtotal - discount;
559
+
560
  // Update UI with discount and total bill
561
  document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
562
  document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;
 
566
  document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
567
  }
568
  }
569
+
570
+
571
+
572
 
573
  function proceedToOrder() {
574
+ let couponDropdown = document.getElementById('couponDropdown');
575
+
576
+ // Initialize selectedCoupon to an empty string by default
577
+ let selectedCoupon = "";
578
+
579
+ // Only proceed if couponDropdown exists
580
+ if (couponDropdown) {
581
+ // If the value is not null or undefined, strip the value
582
+ if (couponDropdown.value != null) {
583
+ selectedCoupon = couponDropdown.value.trim(); // safely call .trim() if value is not null
584
+ } else {
585
+ selectedCoupon = ""; // Assign empty string if value is null
586
+ }
587
+ }
588
+
589
+ // If no coupon is selected or the value is empty, treat it as no coupon
590
+ if (selectedCoupon === "" || selectedCoupon === "None" || selectedCoupon === "Null") {
591
+ selectedCoupon = null; // Treat it as no coupon selected
592
+ }
593
+
594
+ // Send the selected coupon to the backend for processing
595
+ fetch('/checkout', {
596
+ method: 'POST',
597
+ headers: { 'Content-Type': 'application/json' },
598
+ body: JSON.stringify({ selectedCoupon: selectedCoupon })
599
+ })
600
+ .then(response => response.json())
601
+ .then(data => {
602
+ if (data.success) {
603
+ alert(data.message); // Success message
604
+ window.location.href = '/order'; // Redirect to order page
605
+ } else {
606
+ alert(data.error || data.message); // Handle error message
 
607
  }
608
+ })
609
+ .catch(err => console.error('Error during checkout:', err));
610
+ }
611
+
612
+
613
+
614
  function calculateSubtotal() {
615
  let subtotal = 0;
616
  document.querySelectorAll('.cart-item').forEach(item => {
 
619
  const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
620
  subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
621
  });
622
+
623
  // Update the subtotal in the HTML
624
  document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
625
  return subtotal;
 
728
  })
729
  .catch(err => console.error('Error adding item:', err));
730
  }
731
+
732
+
733
 
734
 
735
  </script>
736
 
737
  </body>
738
+ </html>