Spaces:
Sleeping
Sleeping
Update templates/menu.html
Browse files- templates/menu.html +167 -41
templates/menu.html
CHANGED
@@ -555,6 +555,50 @@ form-check-input addon-option{
|
|
555 |
padding: 2px 8px;
|
556 |
font-size: 12px;
|
557 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
</style>
|
559 |
</head>
|
560 |
<body>
|
@@ -671,11 +715,18 @@ form-check-input addon-option{
|
|
671 |
</div>
|
672 |
|
673 |
<!-- View Cart Button -->
|
674 |
-
<div class="view-cart-container">
|
675 |
<a href="{{ url_for('cart.cart') }}" class="view-cart-button">
|
676 |
View Cart
|
677 |
</a>
|
678 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
|
680 |
<!-- Modal for Item Details -->
|
681 |
<div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
|
@@ -963,45 +1014,45 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
963 |
});
|
964 |
|
965 |
// Function to add Soft Drink to cart directly
|
966 |
-
function addSoftDrinkToCart(name, price, image, section, category, index) {
|
967 |
-
const itemPrice = parseFloat(price);
|
968 |
-
const quantity = 1; // Default quantity
|
969 |
-
|
970 |
-
const cartPayload = {
|
971 |
-
itemName: name,
|
972 |
-
itemPrice: itemPrice,
|
973 |
-
itemImage: image || '/static/placeholder.jpg',
|
974 |
-
section: section,
|
975 |
-
category: category,
|
976 |
-
addons: [], // No add-ons for Soft Drinks
|
977 |
-
instructions: '', // No instructions for Soft Drinks
|
978 |
-
quantity: quantity
|
979 |
-
};
|
980 |
-
|
981 |
-
fetch('/cart/add', {
|
982 |
-
method: 'POST',
|
983 |
-
headers: {
|
984 |
-
'Content-Type': 'application/json',
|
985 |
-
},
|
986 |
-
body: JSON.stringify(cartPayload)
|
987 |
-
})
|
988 |
-
.then(response => response.json())
|
989 |
-
.then(data => {
|
990 |
-
if (data.success) {
|
991 |
-
// Hide the ADD button and show quantity controls
|
992 |
-
document.getElementById(`add-btn-${index}`).style.display = 'none';
|
993 |
-
document.getElementById(`quantity-control-${index}`).style.display = 'flex';
|
994 |
-
updateCartUI(data.cart);
|
995 |
-
alert('Soft Drink added to cart successfully!');
|
996 |
-
} else {
|
997 |
-
alert(data.error || 'Failed to add Soft Drink to cart.');
|
998 |
-
}
|
999 |
-
})
|
1000 |
-
.catch(err => {
|
1001 |
-
console.error('Error adding Soft Drink to cart:', err);
|
1002 |
-
alert('An error occurred while adding the Soft Drink to the cart.');
|
1003 |
-
});
|
1004 |
-
}
|
1005 |
// function addSoftDrinkToCart(name, price, image, section, category, index) {
|
1006 |
// const itemPrice = parseFloat(price);
|
1007 |
// const quantity = 1; // Default quantity
|
@@ -1116,6 +1167,81 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
1116 |
// .catch(err => console.error("Error removing item from cart:", err));
|
1117 |
// }
|
1118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1119 |
|
1120 |
|
1121 |
|
|
|
555 |
padding: 2px 8px;
|
556 |
font-size: 12px;
|
557 |
}
|
558 |
+
|
559 |
+
|
560 |
+
|
561 |
+
|
562 |
+
|
563 |
+
|
564 |
+
|
565 |
+
|
566 |
+
#view-cart-container {
|
567 |
+
position: fixed;
|
568 |
+
right: 20px;
|
569 |
+
bottom: 20px;
|
570 |
+
display: none; /* Hide the container initially */
|
571 |
+
transition: right 0.3s ease; /* Smooth transition for movement */
|
572 |
+
}
|
573 |
+
|
574 |
+
.view-cart-button {
|
575 |
+
background-color: #007bff; /* Adjust color as needed */
|
576 |
+
color: white;
|
577 |
+
padding: 10px 20px;
|
578 |
+
border-radius: 5px;
|
579 |
+
text-decoration: none;
|
580 |
+
position: relative;
|
581 |
+
}
|
582 |
+
|
583 |
+
.cart-count {
|
584 |
+
position: absolute;
|
585 |
+
top: -10px;
|
586 |
+
right: -10px;
|
587 |
+
background-color: red;
|
588 |
+
color: white;
|
589 |
+
border-radius: 50%;
|
590 |
+
padding: 5px 10px;
|
591 |
+
font-size: 12px;
|
592 |
+
}
|
593 |
+
|
594 |
+
.show-cart {
|
595 |
+
right: 20px; /* Move the button to the right */
|
596 |
+
}
|
597 |
+
|
598 |
+
.hide-cart {
|
599 |
+
right: -300px; /* Hide it off-screen if needed */
|
600 |
+
}
|
601 |
+
|
602 |
</style>
|
603 |
</head>
|
604 |
<body>
|
|
|
715 |
</div>
|
716 |
|
717 |
<!-- View Cart Button -->
|
718 |
+
<!-- <div class="view-cart-container">
|
719 |
<a href="{{ url_for('cart.cart') }}" class="view-cart-button">
|
720 |
View Cart
|
721 |
</a>
|
722 |
+
</div> -->
|
723 |
+
<div class="view-cart-container" id="view-cart-container">
|
724 |
+
<a href="{{ url_for('cart.cart') }}" class="view-cart-button" id="view-cart-button">
|
725 |
+
<span id="cart-count" class="cart-count">0</span>
|
726 |
+
View Cart
|
727 |
+
</a>
|
728 |
+
</div>
|
729 |
+
|
730 |
|
731 |
<!-- Modal for Item Details -->
|
732 |
<div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
|
|
|
1014 |
});
|
1015 |
|
1016 |
// Function to add Soft Drink to cart directly
|
1017 |
+
// function addSoftDrinkToCart(name, price, image, section, category, index) {
|
1018 |
+
// const itemPrice = parseFloat(price);
|
1019 |
+
// const quantity = 1; // Default quantity
|
1020 |
+
|
1021 |
+
// const cartPayload = {
|
1022 |
+
// itemName: name,
|
1023 |
+
// itemPrice: itemPrice,
|
1024 |
+
// itemImage: image || '/static/placeholder.jpg',
|
1025 |
+
// section: section,
|
1026 |
+
// category: category,
|
1027 |
+
// addons: [], // No add-ons for Soft Drinks
|
1028 |
+
// instructions: '', // No instructions for Soft Drinks
|
1029 |
+
// quantity: quantity
|
1030 |
+
// };
|
1031 |
+
|
1032 |
+
// fetch('/cart/add', {
|
1033 |
+
// method: 'POST',
|
1034 |
+
// headers: {
|
1035 |
+
// 'Content-Type': 'application/json',
|
1036 |
+
// },
|
1037 |
+
// body: JSON.stringify(cartPayload)
|
1038 |
+
// })
|
1039 |
+
// .then(response => response.json())
|
1040 |
+
// .then(data => {
|
1041 |
+
// if (data.success) {
|
1042 |
+
// // Hide the ADD button and show quantity controls
|
1043 |
+
// document.getElementById(`add-btn-${index}`).style.display = 'none';
|
1044 |
+
// document.getElementById(`quantity-control-${index}`).style.display = 'flex';
|
1045 |
+
// updateCartUI(data.cart);
|
1046 |
+
// alert('Soft Drink added to cart successfully!');
|
1047 |
+
// } else {
|
1048 |
+
// alert(data.error || 'Failed to add Soft Drink to cart.');
|
1049 |
+
// }
|
1050 |
+
// })
|
1051 |
+
// .catch(err => {
|
1052 |
+
// console.error('Error adding Soft Drink to cart:', err);
|
1053 |
+
// alert('An error occurred while adding the Soft Drink to the cart.');
|
1054 |
+
// });
|
1055 |
+
// }
|
1056 |
// function addSoftDrinkToCart(name, price, image, section, category, index) {
|
1057 |
// const itemPrice = parseFloat(price);
|
1058 |
// const quantity = 1; // Default quantity
|
|
|
1167 |
// .catch(err => console.error("Error removing item from cart:", err));
|
1168 |
// }
|
1169 |
|
1170 |
+
function addSoftDrinkToCart(name, price, image, section, category, index) {
|
1171 |
+
const itemPrice = parseFloat(price);
|
1172 |
+
const quantity = 1; // Default quantity
|
1173 |
+
|
1174 |
+
const cartPayload = {
|
1175 |
+
itemName: name,
|
1176 |
+
itemPrice: itemPrice,
|
1177 |
+
itemImage: image || '/static/placeholder.jpg',
|
1178 |
+
section: section,
|
1179 |
+
category: category,
|
1180 |
+
addons: [], // No add-ons for Soft Drinks
|
1181 |
+
instructions: '', // No instructions for Soft Drinks
|
1182 |
+
quantity: quantity
|
1183 |
+
};
|
1184 |
+
|
1185 |
+
fetch('/cart/add', {
|
1186 |
+
method: 'POST',
|
1187 |
+
headers: {
|
1188 |
+
'Content-Type': 'application/json',
|
1189 |
+
},
|
1190 |
+
body: JSON.stringify(cartPayload)
|
1191 |
+
})
|
1192 |
+
.then(response => response.json())
|
1193 |
+
.then(data => {
|
1194 |
+
if (data.success) {
|
1195 |
+
// Hide the ADD button and show quantity controls
|
1196 |
+
document.getElementById(`add-btn-${index}`).style.display = 'none';
|
1197 |
+
document.getElementById(`quantity-control-${index}`).style.display = 'flex';
|
1198 |
+
updateCartUI(data.cart);
|
1199 |
+
showCartButton(); // Show the cart button when an item is added
|
1200 |
+
alert('Soft Drink added to cart successfully!');
|
1201 |
+
} else {
|
1202 |
+
alert(data.error || 'Failed to add Soft Drink to cart.');
|
1203 |
+
}
|
1204 |
+
})
|
1205 |
+
.catch(err => {
|
1206 |
+
console.error('Error adding Soft Drink to cart:', err);
|
1207 |
+
alert('An error occurred while adding the Soft Drink to the cart.');
|
1208 |
+
});
|
1209 |
+
}
|
1210 |
+
|
1211 |
+
// Function to show the "View Cart" button and update the count
|
1212 |
+
function showCartButton() {
|
1213 |
+
var cartContainer = document.getElementById("view-cart-container");
|
1214 |
+
var cartButton = document.getElementById("view-cart-button");
|
1215 |
+
var cartCountElement = document.getElementById("cart-count");
|
1216 |
+
|
1217 |
+
// Make the cart container visible
|
1218 |
+
cartContainer.style.display = "block";
|
1219 |
+
|
1220 |
+
// Apply transition to move the button from right to left
|
1221 |
+
setTimeout(function() {
|
1222 |
+
cartContainer.classList.add("show-cart");
|
1223 |
+
}, 10);
|
1224 |
+
|
1225 |
+
updateCartCount(cartCountElement);
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
// Function to update the cart item count
|
1229 |
+
function updateCartCount(cartCountElement) {
|
1230 |
+
// Get the number of items in the cart from your cart data (adjust as needed)
|
1231 |
+
fetch('/cart/total-items') // Replace this with your actual endpoint for cart data
|
1232 |
+
.then(response => response.json())
|
1233 |
+
.then(data => {
|
1234 |
+
if (data.success) {
|
1235 |
+
cartCountElement.textContent = data.totalItems; // Update count
|
1236 |
+
} else {
|
1237 |
+
cartCountElement.textContent = 0; // In case of an error, show 0
|
1238 |
+
}
|
1239 |
+
})
|
1240 |
+
.catch(err => {
|
1241 |
+
console.error('Error fetching cart count:', err);
|
1242 |
+
cartCountElement.textContent = 0; // Fallback in case of an error
|
1243 |
+
});
|
1244 |
+
}
|
1245 |
|
1246 |
|
1247 |
|