Spaces:
Sleeping
Sleeping
Update templates/cart.html
Browse files- templates/cart.html +81 -55
templates/cart.html
CHANGED
@@ -260,53 +260,75 @@
|
|
260 |
align-items: center;
|
261 |
text-align: center;
|
262 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
|
265 |
|
266 |
-
|
267 |
-
|
268 |
-
padding: 15px;
|
269 |
-
background-color: #f8f9fa;
|
270 |
-
border-radius: 10px;
|
271 |
-
}
|
272 |
-
.suggestion-item {
|
273 |
-
display: flex;
|
274 |
-
align-items: center; /* Vertically align image and text */
|
275 |
-
justify-content: space-between; /* Space between the image/text and the button */
|
276 |
-
padding: 10px 0;
|
277 |
-
}
|
278 |
-
.suggestion-item img {
|
279 |
-
width: 50px;
|
280 |
-
height: 50px;
|
281 |
-
object-fit: cover;
|
282 |
-
border-radius: 5px;
|
283 |
-
margin-right: 10px; /* Spacing between the image and the text */
|
284 |
-
}
|
285 |
-
.suggestion-item div {
|
286 |
-
display: flex;
|
287 |
-
flex-direction: column;
|
288 |
-
justify-content: center;
|
289 |
-
flex-grow: 1; /* Allow the text to take up the available space */
|
290 |
-
}
|
291 |
-
.suggestion-item button {
|
292 |
-
padding: 5px 15px;
|
293 |
-
font-size: 12px;
|
294 |
-
border-radius: 5px;
|
295 |
-
border: 2px solid #0FAA39;
|
296 |
-
color: #0FAA39;
|
297 |
-
background-color: #fff;
|
298 |
-
font-weight: 600;
|
299 |
-
height: 44px;
|
300 |
-
width: 100px;
|
301 |
-
cursor: pointer;
|
302 |
-
transition: background-color 0.3s, color 0.3s, border-color 0.3s;
|
303 |
-
margin-left: auto; /* Push button to the right */
|
304 |
-
}
|
305 |
-
.suggestion-item button:hover {
|
306 |
-
background-color: #fff; /* Change background to green on hover */
|
307 |
-
color: #0FAA39; /* Change text color to white on hover */
|
308 |
-
border-color: #0FAA39; /* Keep the border green */
|
309 |
-
}
|
310 |
|
311 |
.remove-icon {
|
312 |
border: none;
|
@@ -365,17 +387,23 @@
|
|
365 |
{% if suggestions %}
|
366 |
<div class="suggestion-section">
|
367 |
<h5>Complete Your Meal</h5>
|
368 |
-
|
369 |
-
|
370 |
-
<
|
371 |
-
|
372 |
-
<div>
|
373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
</div>
|
375 |
-
|
376 |
</div>
|
377 |
-
{% endfor %}
|
378 |
</div>
|
|
|
379 |
{% endif %}
|
380 |
|
381 |
<!-- Subtotal -->
|
@@ -631,8 +659,7 @@
|
|
631 |
}
|
632 |
function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
|
633 |
const customerEmail = "{{ customer_email }}"; // Get customer email from session
|
634 |
-
|
635 |
-
// Create the data object to send to the server
|
636 |
const data = {
|
637 |
item_name: itemName,
|
638 |
item_price: itemPrice,
|
@@ -642,7 +669,6 @@
|
|
642 |
instructions: "", // Default to empty, you can adjust if needed
|
643 |
customer_email: customerEmail
|
644 |
};
|
645 |
-
|
646 |
// Send the data to the backend via a POST request
|
647 |
fetch('/cart/add_suggestion_to_cart', {
|
648 |
method: 'POST',
|
|
|
260 |
align-items: center;
|
261 |
text-align: center;
|
262 |
}
|
263 |
+
.suggestion-section {
|
264 |
+
margin-top: 20px;
|
265 |
+
padding: 15px;
|
266 |
+
background-color: #f8f9fa;
|
267 |
+
border-radius: 10px;
|
268 |
+
}
|
269 |
+
|
270 |
+
.suggestion-items-container {
|
271 |
+
display: flex; /* Align the items in a row */
|
272 |
+
overflow-x: auto; /* Make the container scrollable horizontally */
|
273 |
+
gap: 15px; /* Add space between items */
|
274 |
+
padding-bottom: 10px; /* Add padding at the bottom for scrollbar */
|
275 |
+
}
|
276 |
+
|
277 |
+
.suggestion-item {
|
278 |
+
display: flex;
|
279 |
+
align-items: center;
|
280 |
+
justify-content: center;
|
281 |
+
flex-shrink: 0; /* Prevent items from shrinking */
|
282 |
+
width: 150px; /* Set a fixed width for each suggestion item */
|
283 |
+
padding: 10px;
|
284 |
+
border-radius: 10px;
|
285 |
+
background-color: #fff;
|
286 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
287 |
+
transition: transform 0.3s ease;
|
288 |
+
}
|
289 |
+
|
290 |
+
.suggestion-item:hover {
|
291 |
+
transform: scale(1.05); /* Add zoom effect on hover */
|
292 |
+
}
|
293 |
+
|
294 |
+
.suggestion-item img {
|
295 |
+
width: 60px;
|
296 |
+
height: 60px;
|
297 |
+
object-fit: cover;
|
298 |
+
border-radius: 5px;
|
299 |
+
margin-right: 10px;
|
300 |
+
}
|
301 |
+
|
302 |
+
.suggestion-item div {
|
303 |
+
flex-grow: 1; /* Allow text to take up available space */
|
304 |
+
}
|
305 |
+
|
306 |
+
.add-back-button {
|
307 |
+
padding: 6px 20px;
|
308 |
+
font-size: 0.9rem;
|
309 |
+
border-radius: 20px;
|
310 |
+
border: 1px solid #fff;
|
311 |
+
background-color: #fff;
|
312 |
+
color: #0FAA39;
|
313 |
+
cursor: pointer;
|
314 |
+
transition: background-color 0.3s, color 0.3s;
|
315 |
+
}
|
316 |
+
|
317 |
+
.add-back-button:hover {
|
318 |
+
background-color: #0FAA39;
|
319 |
+
color: #fff;
|
320 |
+
border-color: #0FAA39;
|
321 |
+
}
|
322 |
+
|
323 |
+
.bi-cart-plus {
|
324 |
+
font-size: 1.2rem;
|
325 |
+
margin-right: 5px; /* Space between icon and text */
|
326 |
+
}
|
327 |
|
328 |
|
329 |
|
330 |
+
|
331 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
|
333 |
.remove-icon {
|
334 |
border: none;
|
|
|
387 |
{% if suggestions %}
|
388 |
<div class="suggestion-section">
|
389 |
<h5>Complete Your Meal</h5>
|
390 |
+
<div class="suggestion-items-container">
|
391 |
+
{% for suggestion in suggestions %}
|
392 |
+
<div class="suggestion-item">
|
393 |
+
<img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
|
394 |
+
<div>
|
395 |
+
<div>{{ suggestion.Name }}</div>
|
396 |
+
<div class="text-muted">${{ suggestion.Price__c }}</div>
|
397 |
+
</div>
|
398 |
+
<!-- Replace add button with a cart icon -->
|
399 |
+
<button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}', '{{ suggestion.Id }}')">
|
400 |
+
<i class="bi bi-cart-plus"></i> <!-- Cart icon -->
|
401 |
+
</button>
|
402 |
</div>
|
403 |
+
{% endfor %}
|
404 |
</div>
|
|
|
405 |
</div>
|
406 |
+
|
407 |
{% endif %}
|
408 |
|
409 |
<!-- Subtotal -->
|
|
|
659 |
}
|
660 |
function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
|
661 |
const customerEmail = "{{ customer_email }}"; // Get customer email from session
|
662 |
+
// Create the data object to send to the ser ver
|
|
|
663 |
const data = {
|
664 |
item_name: itemName,
|
665 |
item_price: itemPrice,
|
|
|
669 |
instructions: "", // Default to empty, you can adjust if needed
|
670 |
customer_email: customerEmail
|
671 |
};
|
|
|
672 |
// Send the data to the backend via a POST request
|
673 |
fetch('/cart/add_suggestion_to_cart', {
|
674 |
method: 'POST',
|