Spaces:
Runtime error
Runtime error
Update templates/cart.html (#1)
Browse files- Update templates/cart.html (8f92c879482ed12c97df52075e457f1ef42af869)
Co-authored-by: Surendra <[email protected]>
- templates/cart.html +450 -163
templates/cart.html
CHANGED
|
@@ -7,50 +7,137 @@
|
|
| 7 |
<!-- Bootstrap CSS -->
|
| 8 |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 9 |
<style>
|
| 10 |
-
|
|
|
|
| 11 |
font-family: Arial, sans-serif;
|
| 12 |
-
background-color: #
|
|
|
|
| 13 |
}
|
| 14 |
.cart-container {
|
| 15 |
max-width: 768px;
|
| 16 |
margin: 20px auto;
|
| 17 |
padding: 15px;
|
| 18 |
-
background-color: #
|
| 19 |
border-radius: 10px;
|
| 20 |
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
.cart-item {
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
.cart-item img {
|
| 30 |
-
width:
|
| 31 |
-
height:
|
| 32 |
-
object-fit:
|
| 33 |
-
border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
.cart-item-details {
|
| 36 |
flex: 1;
|
| 37 |
margin-left: 15px;
|
| 38 |
}
|
| 39 |
-
|
| 40 |
-
font-size: 1rem;
|
| 41 |
-
font-weight: bold;
|
| 42 |
-
}
|
| 43 |
.cart-item-quantity {
|
| 44 |
display: flex;
|
| 45 |
align-items: center;
|
| 46 |
margin-top: 5px;
|
| 47 |
}
|
| 48 |
.cart-item-quantity button {
|
| 49 |
-
width:
|
| 50 |
-
height:
|
| 51 |
border: none;
|
| 52 |
background-color: #f0f0f0;
|
| 53 |
-
font-size:
|
| 54 |
font-weight: bold;
|
| 55 |
cursor: pointer;
|
| 56 |
}
|
|
@@ -62,52 +149,214 @@
|
|
| 62 |
font-size: 1rem;
|
| 63 |
margin: 0 5px;
|
| 64 |
}
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
</style>
|
| 112 |
</head>
|
| 113 |
<body>
|
|
@@ -117,81 +366,118 @@
|
|
| 117 |
<a href="/menu" style="text-decoration: none; font-size: 1.5rem; color: #007bff;">×</a>
|
| 118 |
</div>
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
<!-- Cart Items -->
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
<
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
</div>
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
| 149 |
</div>
|
| 150 |
-
{% else %}
|
| 151 |
-
<p class="text-center">Your cart is empty.</p>
|
| 152 |
-
{% endfor %}
|
| 153 |
|
| 154 |
<!-- Suggestions Section -->
|
| 155 |
{% if suggestions %}
|
| 156 |
<div class="suggestion-section">
|
| 157 |
<h5>Complete Your Meal</h5>
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
<
|
| 161 |
-
|
| 162 |
-
<div>
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
</div>
|
| 165 |
-
|
| 166 |
</div>
|
| 167 |
-
{% endfor %}
|
| 168 |
</div>
|
|
|
|
| 169 |
{% endif %}
|
| 170 |
|
| 171 |
<!-- Subtotal -->
|
| 172 |
<div class="cart-summary">
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
<button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
|
| 191 |
</div>
|
| 192 |
</div>
|
| 193 |
</div>
|
| 194 |
|
|
|
|
| 195 |
<script>
|
| 196 |
// Example function to handle the increase/decrease button clicks
|
| 197 |
function updateQuantity(action, itemName, customerEmail) {
|
|
@@ -203,11 +489,13 @@
|
|
| 203 |
} else if (action === 'decrease' && quantity > 1) {
|
| 204 |
quantity--;
|
| 205 |
}
|
|
|
|
| 206 |
// Validate quantity
|
| 207 |
if (isNaN(quantity) || quantity < 1) {
|
| 208 |
alert("Invalid quantity!");
|
| 209 |
return;
|
| 210 |
}
|
|
|
|
| 211 |
// Send updated quantity to the server
|
| 212 |
fetch('/cart/update_quantity', {
|
| 213 |
method: 'POST',
|
|
@@ -223,10 +511,12 @@
|
|
| 223 |
if (itemElement) {
|
| 224 |
let basePriceElement = itemElement.querySelector(".base-price");
|
| 225 |
let addonsPriceElement = itemElement.querySelector(".addons-price");
|
|
|
|
| 226 |
// Update the base price
|
| 227 |
if (basePriceElement) {
|
| 228 |
basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
|
| 229 |
}
|
|
|
|
| 230 |
// Update add-ons price if needed (optional)
|
| 231 |
if (addonsPriceElement && data.addons_price !== undefined) {
|
| 232 |
addonsPriceElement.innerText = data.addons_price.toFixed(2);
|
|
@@ -235,6 +525,7 @@
|
|
| 235 |
console.error(`Parent cart item element not found for item: ${itemName}`);
|
| 236 |
}
|
| 237 |
location.reload();
|
|
|
|
| 238 |
// Recalculate subtotal dynamically
|
| 239 |
|
| 240 |
} else {
|
|
@@ -244,60 +535,51 @@
|
|
| 244 |
.catch(err => console.error("Error:", err));
|
| 245 |
}
|
| 246 |
function toggleCouponDropdown() {
|
| 247 |
-
let couponCheckbox = document.getElementById('couponCheckbox');
|
| 248 |
let couponDropdown = document.getElementById('couponDropdown');
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
}
|
| 256 |
}
|
|
|
|
|
|
|
| 257 |
function calculateDiscount() {
|
| 258 |
-
let
|
| 259 |
-
let
|
| 260 |
-
let subtotal = parseFloat("{{ subtotal }}");
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
if (!selectedCoupon || selectedCoupon.toLowerCase() === "none") {
|
| 265 |
-
alert("Please select a valid coupon.");
|
| 266 |
-
document.getElementById("discountText").innerText = `Discount: $0`;
|
| 267 |
-
document.getElementById("totalBillText").innerText = `Total Bill: $${subtotal.toFixed(2)}`;
|
| 268 |
-
return;
|
| 269 |
-
}
|
| 270 |
-
|
| 271 |
// Apply 10% discount
|
| 272 |
let discount = subtotal * 0.10;
|
| 273 |
let total = subtotal - discount;
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
document.getElementById("
|
|
|
|
| 277 |
} else {
|
| 278 |
-
// If
|
| 279 |
-
document.getElementById("discountText").innerText =
|
| 280 |
-
document.getElementById("totalBillText").innerText =
|
| 281 |
}
|
| 282 |
}
|
|
|
|
|
|
|
|
|
|
| 283 |
function proceedToOrder() {
|
| 284 |
-
let couponCheckbox = document.getElementById('couponCheckbox');
|
| 285 |
let couponDropdown = document.getElementById('couponDropdown');
|
| 286 |
-
let selectedCoupon =
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
if (!selectedCoupon) {
|
| 293 |
-
alert("Please select a valid coupon before proceeding.");
|
| 294 |
-
return;
|
| 295 |
-
}
|
| 296 |
-
} else {
|
| 297 |
-
alert("Error: Coupon dropdown not found.");
|
| 298 |
-
return;
|
| 299 |
-
}
|
| 300 |
}
|
|
|
|
|
|
|
| 301 |
fetch('/checkout', {
|
| 302 |
method: 'POST',
|
| 303 |
headers: { 'Content-Type': 'application/json' },
|
|
@@ -307,13 +589,15 @@
|
|
| 307 |
.then(data => {
|
| 308 |
if (data.success) {
|
| 309 |
alert(data.message);
|
| 310 |
-
window.location.href = '/order';
|
| 311 |
} else {
|
| 312 |
alert(data.error || data.message);
|
| 313 |
}
|
| 314 |
})
|
| 315 |
.catch(err => console.error('Error during checkout:', err));
|
| 316 |
}
|
|
|
|
|
|
|
| 317 |
function calculateSubtotal() {
|
| 318 |
let subtotal = 0;
|
| 319 |
document.querySelectorAll('.cart-item').forEach(item => {
|
|
@@ -322,6 +606,7 @@
|
|
| 322 |
const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
|
| 323 |
subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
|
| 324 |
});
|
|
|
|
| 325 |
// Update the subtotal in the HTML
|
| 326 |
document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
|
| 327 |
return subtotal;
|
|
@@ -401,7 +686,7 @@
|
|
| 401 |
}
|
| 402 |
function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
|
| 403 |
const customerEmail = "{{ customer_email }}"; // Get customer email from session
|
| 404 |
-
// Create the data object to send to the
|
| 405 |
const data = {
|
| 406 |
item_name: itemName,
|
| 407 |
item_price: itemPrice,
|
|
@@ -430,6 +715,8 @@
|
|
| 430 |
})
|
| 431 |
.catch(err => console.error('Error adding item:', err));
|
| 432 |
}
|
|
|
|
|
|
|
| 433 |
|
| 434 |
|
| 435 |
</script>
|
|
|
|
| 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: #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;
|
| 33 |
+
border: 1px solid transparent; /* Set the border to transparent */
|
| 34 |
+
padding: 30px 15px 15px;
|
| 35 |
+
background-color: #fff;/* Padding for the content */
|
| 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 */
|
| 55 |
+
background-color: transparent; /* Keep background transparent on hover */
|
| 56 |
+
}
|
| 57 |
+
/* Prevent background color on focus or click */
|
| 58 |
+
.remove-btn:focus {
|
| 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;
|
| 112 |
+
font-size: 0.9rem;
|
| 113 |
+
border-radius: 20px;
|
| 114 |
+
border: 1px solid #fff;
|
| 115 |
+
background-color: #fff;
|
| 116 |
+
color: #0FAA39;
|
| 117 |
+
cursor: pointer;
|
| 118 |
+
transition: background-color 0.3s, color 0.3s;
|
| 119 |
+
}
|
| 120 |
+
.add-back-button:hover {
|
| 121 |
+
background-color: #fff;
|
| 122 |
+
color: #0FAA39;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
.cart-item-details {
|
| 126 |
flex: 1;
|
| 127 |
margin-left: 15px;
|
| 128 |
}
|
| 129 |
+
|
|
|
|
|
|
|
|
|
|
| 130 |
.cart-item-quantity {
|
| 131 |
display: flex;
|
| 132 |
align-items: center;
|
| 133 |
margin-top: 5px;
|
| 134 |
}
|
| 135 |
.cart-item-quantity button {
|
| 136 |
+
width: 24px;
|
| 137 |
+
height: 24px;
|
| 138 |
border: none;
|
| 139 |
background-color: #f0f0f0;
|
| 140 |
+
font-size: 0.8rem;
|
| 141 |
font-weight: bold;
|
| 142 |
cursor: pointer;
|
| 143 |
}
|
|
|
|
| 149 |
font-size: 1rem;
|
| 150 |
margin: 0 5px;
|
| 151 |
}
|
| 152 |
+
/* Make the parent container position relative */
|
| 153 |
+
.cart-summary {
|
| 154 |
+
position: relative; /* Make sure dropdown is positioned relative to this container */
|
| 155 |
+
text-align: left;
|
| 156 |
+
margin-top: 15px;
|
| 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 {
|
| 164 |
+
display: flex; /* Use flexbox to align items */
|
| 165 |
+
justify-content: space-between; /* Space between the label and the link */
|
| 166 |
+
align-items: center;
|
| 167 |
+
font-size: 1rem;
|
| 168 |
+
margin-bottom: 20px; /* Add space below Apply Coupon section */
|
| 169 |
+
position: relative; /* Ensure dropdown is within this container */
|
| 170 |
+
}
|
| 171 |
+
/* Ensure the Apply Coupon label and link are aligned correctly */
|
| 172 |
+
.coupon-selection label {
|
| 173 |
+
font-weight: bold;
|
| 174 |
+
color: black;
|
| 175 |
+
}
|
| 176 |
+
.coupon-selection a {
|
| 177 |
+
color: #007bff; /* Blue for the link */
|
| 178 |
+
font-size: 1rem;
|
| 179 |
+
text-decoration: none;
|
| 180 |
+
text-align: right;
|
| 181 |
+
}
|
| 182 |
+
/* Coupon Dropdown styling */
|
| 183 |
+
#couponDropdown {
|
| 184 |
+
width: 30%; /* Set dropdown to 30% of the width */
|
| 185 |
+
display: none; /* Hidden by default */
|
| 186 |
+
background-color: #fff;
|
| 187 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Add shadow */
|
| 188 |
+
z-index: 10; /* Ensure it's above other content */
|
| 189 |
+
margin-top: 10px; /* Add space from the link */
|
| 190 |
+
margin-left: auto; /* Push it to the right side */
|
| 191 |
+
margin-right: 0; /* Ensure it doesn't overflow outside */
|
| 192 |
+
}
|
| 193 |
+
/* Show the dropdown when it's active */
|
| 194 |
+
#couponDropdown.show {
|
| 195 |
+
display: block;
|
| 196 |
+
}
|
| 197 |
+
/* Ensure Apply Coupon section aligns correctly */
|
| 198 |
+
.coupon-selection {
|
| 199 |
+
display: flex;
|
| 200 |
+
justify-content: space-between;
|
| 201 |
+
align-items: center;
|
| 202 |
+
font-size: 1rem;
|
| 203 |
+
margin-bottom: 20px; /* Add space below Apply Coupon section */
|
| 204 |
+
}
|
| 205 |
+
/* Apply Coupon link and label styles */
|
| 206 |
+
.coupon-selection label {
|
| 207 |
+
font-weight: bold;
|
| 208 |
+
color: black;
|
| 209 |
+
}
|
| 210 |
+
.coupon-selection a {
|
| 211 |
+
color: #007bff; /* Blue for the link */
|
| 212 |
+
font-size: 1rem;
|
| 213 |
+
text-decoration: none;
|
| 214 |
+
text-align: right;
|
| 215 |
+
}
|
| 216 |
+
/* Bill details grid structure */
|
| 217 |
+
.bill-details {
|
| 218 |
+
display: grid;
|
| 219 |
+
grid-template-columns: 1fr 1fr; /* Two-column layout */
|
| 220 |
+
grid-gap: 10px;
|
| 221 |
+
margin-bottom: 10px;
|
| 222 |
+
}
|
| 223 |
+
/* Adjust label and amount for bill details */
|
| 224 |
+
.bill-details .label {
|
| 225 |
+
font-weight: 600;
|
| 226 |
+
font-size: 1rem;
|
| 227 |
+
}
|
| 228 |
+
.bill-details .amount {
|
| 229 |
+
text-align: right;
|
| 230 |
+
font-weight: 600;
|
| 231 |
+
font-size: 1rem;
|
| 232 |
+
}
|
| 233 |
+
/* Divider line between bill sections */
|
| 234 |
+
.dotted-line {
|
| 235 |
+
border-bottom: 2px dotted #ccc;
|
| 236 |
+
margin: 15px 0;
|
| 237 |
+
}
|
| 238 |
+
/* Total bill grid layout */
|
| 239 |
+
.total-bill {
|
| 240 |
+
display: grid;
|
| 241 |
+
grid-template-columns: 1fr 1fr;
|
| 242 |
+
font-weight: 600;
|
| 243 |
+
font-size: 1.2rem;
|
| 244 |
+
margin-top: 10px;
|
| 245 |
+
margin-bottom: 10px; /* Add 10px space between To Pay and Submit Button */
|
| 246 |
+
}
|
| 247 |
+
.total-bill .label {
|
| 248 |
+
font-size: 1.1rem;
|
| 249 |
+
}
|
| 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;
|
| 265 |
+
height: 44px;
|
| 266 |
+
width: 100%;
|
| 267 |
+
font-size: 1.2rem;
|
| 268 |
+
cursor: pointer;
|
| 269 |
+
transition: background-color 0.3s, color 0.3s;
|
| 270 |
+
display: flex;
|
| 271 |
+
justify-content: center;
|
| 272 |
+
align-items: center;
|
| 273 |
+
text-align: center;
|
| 274 |
+
}
|
| 275 |
+
.suggestion-section {
|
| 276 |
+
margin-top: 25px;
|
| 277 |
+
padding: 15px;
|
| 278 |
+
background-color: #fff;
|
| 279 |
+
border-radius: 10px;
|
| 280 |
+
}
|
| 281 |
+
.suggestion-items-container {
|
| 282 |
+
display: flex;
|
| 283 |
+
overflow-x: auto; /* Horizontal scrolling */
|
| 284 |
+
gap: 10px; /* Space between items */
|
| 285 |
+
padding-bottom: 10px;
|
| 286 |
+
padding-top: 10px;
|
| 287 |
+
}
|
| 288 |
+
/* Styling for the suggestion item card */
|
| 289 |
+
.suggestion-item {
|
| 290 |
+
display: flex; /* Align items horizontally */
|
| 291 |
+
align-items: center; /* Center image and text vertically */
|
| 292 |
+
justify-content: flex-start; /* Align items to the start (left side) */
|
| 293 |
+
flex-shrink: 0;
|
| 294 |
+
width: 160px; /* Set fixed width for each suggestion item */
|
| 295 |
+
padding: 10px;
|
| 296 |
+
border-radius: 8px; /* Rounded corners */
|
| 297 |
+
background-color: #fff;
|
| 298 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
| 299 |
+
transition: transform 0.3s ease;
|
| 300 |
+
margin-right: 10px; /* Ensure there's space between the cards */
|
| 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 */
|
| 307 |
+
}
|
| 308 |
+
.suggestion-item img {
|
| 309 |
+
width: 50px; /* Set a fixed width for the image */
|
| 310 |
+
height: 50px; /* Set a fixed height for the image */
|
| 311 |
+
object-fit: cover; /* Ensure image fits correctly without distortion */
|
| 312 |
+
border-radius: 5px; /* Rounded corners for the image */
|
| 313 |
+
margin-right: 12px; /* Space between the image and text */
|
| 314 |
+
}
|
| 315 |
+
.suggestion-item div {
|
| 316 |
+
flex-grow: 1; /* Allow the text section to expand and fill available space */
|
| 317 |
+
text-align: left; /* Align text to the left */
|
| 318 |
+
}
|
| 319 |
+
/* Styling for the + symbol button (with green border, white background, and black text) */
|
| 320 |
+
.add-back-button {
|
| 321 |
+
position: absolute;
|
| 322 |
+
top: -5px;
|
| 323 |
+
right: -10px;
|
| 324 |
+
font-size: 1rem; /* Smaller font size */
|
| 325 |
+
padding: 0; /* Remove padding */
|
| 326 |
+
width: 30px; /* Set fixed width */
|
| 327 |
+
height: 30px; /* Set fixed height */
|
| 328 |
+
background-color: #fff;
|
| 329 |
+
color: #0FAA39;
|
| 330 |
+
border: 2px solid #0FAA39;
|
| 331 |
+
border-radius: 0; /* Square shape */
|
| 332 |
+
cursor: pointer;
|
| 333 |
+
transition: background-color 0.3s, color 0.3s, border-color 0.3s;
|
| 334 |
+
z-index: 2; /* Increased z-index to ensure it stays above the borders */
|
| 335 |
+
}
|
| 336 |
+
.add-back-button:hover {
|
| 337 |
+
background-color: #fff; /* Green background on hover */
|
| 338 |
+
color: #0FAA39; /* White color for the + symbol when hovered */
|
| 339 |
+
border-color: #0FAA39; /* Green border on hover */
|
| 340 |
+
z-index: 3; /* Ensure button stays on top when hovered */
|
| 341 |
+
}
|
| 342 |
+
/* Ensure the scroll container works fine */
|
| 343 |
+
.suggestion-items-container::-webkit-scrollbar {
|
| 344 |
+
height: 8px; /* Height of the scrollbar */
|
| 345 |
+
}
|
| 346 |
+
.suggestion-items-container::-webkit-scrollbar-thumb {
|
| 347 |
+
background-color: #fff; /* Green color for scrollbar thumb */
|
| 348 |
+
border-radius: 4px;
|
| 349 |
+
}
|
| 350 |
+
.suggestion-items-container::-webkit-scrollbar-track {
|
| 351 |
+
background-color: #f1f1f1;
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
.cart-item-actions {
|
| 355 |
+
display: flex; /* Use flexbox to align items horizontally */
|
| 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>
|
|
|
|
| 366 |
<a href="/menu" style="text-decoration: none; font-size: 1.5rem; color: #007bff;">×</a>
|
| 367 |
</div>
|
| 368 |
|
| 369 |
+
<h4 class="mb-4 fw-bold">Your Cart</h4>
|
| 370 |
|
| 371 |
<!-- Cart Items -->
|
| 372 |
+
<div class="cart-container2">
|
| 373 |
+
{% for item in cart_items %}
|
| 374 |
+
<div class="cart-item">
|
| 375 |
+
<div class="image-wrapper">
|
| 376 |
+
<img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
|
| 377 |
+
</div>
|
| 378 |
+
<div class="cart-item-details">
|
| 379 |
+
<div class="cart-item-title">
|
| 380 |
+
{{ item.Name }}
|
| 381 |
+
</div>
|
| 382 |
+
<div class="cart-item-addons">
|
| 383 |
+
<small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
|
| 384 |
+
</div>
|
| 385 |
+
<div class="cart-item-instructions">
|
| 386 |
+
<small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
|
| 387 |
+
</div>
|
| 388 |
+
<div class="cart-item-quantity mt-2">
|
| 389 |
+
<button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
|
| 390 |
+
<input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
|
| 391 |
+
<button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
|
| 392 |
+
</div>
|
| 393 |
+
</div>
|
| 394 |
+
<div class="cart-item-actions">
|
| 395 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
|
| 396 |
+
|
| 397 |
+
<!-- Delete Button with Trash Icon and onclick handler -->
|
| 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 |
+
|
| 402 |
+
<div class="text-primary" style="color: #000 !important;">
|
| 403 |
+
$<span class="base-price">{{ item.Price__c }}</span>
|
| 404 |
+
</div>
|
| 405 |
+
</div>
|
| 406 |
</div>
|
| 407 |
+
{% else %}
|
| 408 |
+
<!-- Code to handle the case when cart_items is empty -->
|
| 409 |
+
<p>No items in your cart.</p>
|
| 410 |
+
{% endfor %}
|
| 411 |
</div>
|
|
|
|
|
|
|
|
|
|
| 412 |
|
| 413 |
<!-- Suggestions Section -->
|
| 414 |
{% if suggestions %}
|
| 415 |
<div class="suggestion-section">
|
| 416 |
<h5>Complete Your Meal</h5>
|
| 417 |
+
<div class="suggestion-items-container">
|
| 418 |
+
{% for suggestion in suggestions %}
|
| 419 |
+
<div class="suggestion-item">
|
| 420 |
+
<img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
|
| 421 |
+
<div>
|
| 422 |
+
<div>{{ suggestion.Name }}</div>
|
| 423 |
+
<div class="text-muted">${{ suggestion.Price__c }}</div>
|
| 424 |
+
</div>
|
| 425 |
+
<!-- Replace add button with a cart icon -->
|
| 426 |
+
<button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}', '{{ suggestion.Id }}')">+</button>
|
| 427 |
+
|
| 428 |
+
|
| 429 |
</div>
|
| 430 |
+
{% endfor %}
|
| 431 |
</div>
|
|
|
|
| 432 |
</div>
|
| 433 |
+
|
| 434 |
{% endif %}
|
| 435 |
|
| 436 |
<!-- Subtotal -->
|
| 437 |
<div class="cart-summary">
|
| 438 |
+
<!-- Coupon Section -->
|
| 439 |
+
{% if coupons %}
|
| 440 |
+
<div class="coupon-selection d-flex justify-content-between align-items-center">
|
| 441 |
+
<label class="text-dark font-weight-bold mb-0">Apply Coupon</label>
|
| 442 |
+
<a href="javascript:void(0);" id="applyCouponLink" onclick="toggleCouponDropdown()" class="text-primary">+ Apply Coupon</a>
|
| 443 |
+
</div>
|
| 444 |
+
|
| 445 |
+
<!-- Coupon Dropdown, positioned below Apply Coupon -->
|
| 446 |
+
<select id="couponDropdown" class="form-select mt-2" style="display:none;" onchange="calculateDiscount()">
|
| 447 |
+
<option value="">Select a coupon</option>
|
| 448 |
+
{% for coupon in coupons %}
|
| 449 |
+
<option value="{{ coupon }}">{{ coupon }}</option>
|
| 450 |
+
{% endfor %}
|
| 451 |
+
</select>
|
| 452 |
+
{% endif %}
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
|
| 456 |
+
<div class="bill-details">
|
| 457 |
+
<div class="label">Cart Total</div>
|
| 458 |
+
<div class="amount">${{ subtotal }}</div>
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
<div class="label">Discount</div>
|
| 462 |
+
<div class="amount" id="discountText">-${{ discount }}</div>
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
</div>
|
| 468 |
+
|
| 469 |
+
<div class="dotted-line"></div>
|
| 470 |
+
|
| 471 |
+
<div class="total-bill">
|
| 472 |
+
<div class="label">To Pay</div>
|
| 473 |
+
<div class="amount" id="totalBillText">${{ subtotal }}</div>
|
| 474 |
+
</div>
|
| 475 |
<button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
|
| 476 |
</div>
|
| 477 |
</div>
|
| 478 |
</div>
|
| 479 |
|
| 480 |
+
|
| 481 |
<script>
|
| 482 |
// Example function to handle the increase/decrease button clicks
|
| 483 |
function updateQuantity(action, itemName, customerEmail) {
|
|
|
|
| 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 {
|
|
|
|
| 535 |
.catch(err => console.error("Error:", err));
|
| 536 |
}
|
| 537 |
function toggleCouponDropdown() {
|
|
|
|
| 538 |
let couponDropdown = document.getElementById('couponDropdown');
|
| 539 |
+
|
| 540 |
+
// Toggle the visibility of the coupon dropdown
|
| 541 |
+
if (couponDropdown.style.display === "none" || couponDropdown.style.display === "") {
|
| 542 |
+
couponDropdown.style.display = "block";
|
| 543 |
+
} 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)}`;
|
| 563 |
} else {
|
| 564 |
+
// If no coupon is selected or "None" is selected, reset the discount
|
| 565 |
+
document.getElementById("discountText").innerText = `$0.00`;
|
| 566 |
+
document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
|
| 567 |
}
|
| 568 |
}
|
| 569 |
+
|
| 570 |
+
|
| 571 |
+
|
| 572 |
function proceedToOrder() {
|
|
|
|
| 573 |
let couponDropdown = document.getElementById('couponDropdown');
|
| 574 |
+
let selectedCoupon = couponDropdown.value.trim(); // Get selected coupon from the dropdown
|
| 575 |
+
|
| 576 |
+
// If no coupon is selected, alert the user
|
| 577 |
+
if (selectedCoupon === "None" || selectedCoupon === "Null") {
|
| 578 |
+
alert("Please select a valid coupon before proceeding.");
|
| 579 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
}
|
| 581 |
+
|
| 582 |
+
// Send the selected coupon to the backend for processing
|
| 583 |
fetch('/checkout', {
|
| 584 |
method: 'POST',
|
| 585 |
headers: { 'Content-Type': 'application/json' },
|
|
|
|
| 589 |
.then(data => {
|
| 590 |
if (data.success) {
|
| 591 |
alert(data.message);
|
| 592 |
+
window.location.href = '/order'; // Redirect to order page
|
| 593 |
} else {
|
| 594 |
alert(data.error || data.message);
|
| 595 |
}
|
| 596 |
})
|
| 597 |
.catch(err => console.error('Error during checkout:', err));
|
| 598 |
}
|
| 599 |
+
|
| 600 |
+
|
| 601 |
function calculateSubtotal() {
|
| 602 |
let subtotal = 0;
|
| 603 |
document.querySelectorAll('.cart-item').forEach(item => {
|
|
|
|
| 606 |
const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
|
| 607 |
subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
|
| 608 |
});
|
| 609 |
+
|
| 610 |
// Update the subtotal in the HTML
|
| 611 |
document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
|
| 612 |
return subtotal;
|
|
|
|
| 686 |
}
|
| 687 |
function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
|
| 688 |
const customerEmail = "{{ customer_email }}"; // Get customer email from session
|
| 689 |
+
// Create the data object to send to the ser ver
|
| 690 |
const data = {
|
| 691 |
item_name: itemName,
|
| 692 |
item_price: itemPrice,
|
|
|
|
| 715 |
})
|
| 716 |
.catch(err => console.error('Error adding item:', err));
|
| 717 |
}
|
| 718 |
+
|
| 719 |
+
|
| 720 |
|
| 721 |
|
| 722 |
</script>
|