Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -152,6 +152,13 @@ def modal_js():
|
|
152 |
<script>
|
153 |
let cart = [];
|
154 |
let totalCartCost = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
function openModal(name, image2, description, price) {
|
156 |
const modal = document.getElementById('modal');
|
157 |
modal.style.display = 'block';
|
@@ -168,9 +175,11 @@ def modal_js():
|
|
168 |
document.getElementById('special-instructions').value = '';
|
169 |
resetAddOns(); // Reset add-ons when opening the modal
|
170 |
}
|
|
|
171 |
function closeModal() {
|
172 |
document.getElementById('modal').style.display = 'none';
|
173 |
}
|
|
|
174 |
function addToCart() {
|
175 |
const name = document.getElementById('modal-name').innerText;
|
176 |
const price = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
|
@@ -184,6 +193,7 @@ def modal_js():
|
|
184 |
}));
|
185 |
const extrasCost = extras.reduce((total, extra) => total + (extra.price * extra.quantity), 0);
|
186 |
const totalCost = (price * quantity) + extrasCost;
|
|
|
187 |
// Add the item to the cart with its specific add-ons
|
188 |
cart.push({ name, price, quantity, extras, instructions, totalCost });
|
189 |
totalCartCost += totalCost; // Update the total cost of the cart
|
@@ -191,10 +201,12 @@ def modal_js():
|
|
191 |
updateCartTotalCost(); // Update total cost displayed
|
192 |
closeModal();
|
193 |
}
|
|
|
194 |
function updateCartButton() {
|
195 |
const cartButton = document.getElementById('cart-button');
|
196 |
cartButton.innerText = `View Cart (${cart.length} items)`;
|
197 |
}
|
|
|
198 |
function openCartModal() {
|
199 |
const cartModal = document.getElementById('cart-modal');
|
200 |
const cartItemsContainer = document.getElementById('cart-items');
|
@@ -214,9 +226,11 @@ def modal_js():
|
|
214 |
});
|
215 |
cartModal.style.display = 'block';
|
216 |
}
|
|
|
217 |
function closeCartModal() {
|
218 |
document.getElementById('cart-modal').style.display = 'none';
|
219 |
}
|
|
|
220 |
function removeFromCart(index) {
|
221 |
totalCartCost -= cart[index].totalCost; // Deduct the cost of the removed item from total cost
|
222 |
cart.splice(index, 1);
|
@@ -224,11 +238,13 @@ def modal_js():
|
|
224 |
updateCartTotalCost(); // Update total cost displayed
|
225 |
openCartModal();
|
226 |
}
|
|
|
227 |
function updateCartTotalCost() {
|
228 |
const totalCostElement = document.getElementById('cart-total-cost');
|
229 |
totalCartCost = cart.reduce((total, item) => total + item.totalCost, 0);
|
230 |
totalCostElement.innerText = `Total Cart Cost: $${totalCartCost.toFixed(2)}`;
|
231 |
}
|
|
|
232 |
function proceedToCheckout() {
|
233 |
const checkoutModal = document.getElementById('final-order-section');
|
234 |
let finalOrderHTML = "<h1>Final Order</h1>";
|
|
|
152 |
<script>
|
153 |
let cart = [];
|
154 |
let totalCartCost = 0;
|
155 |
+
|
156 |
+
// Reset add-ons to none when a new item modal is opened
|
157 |
+
function resetAddOns() {
|
158 |
+
const checkboxes = document.querySelectorAll('input[name="biryani-extra"]');
|
159 |
+
checkboxes.forEach(checkbox => checkbox.checked = false); // Uncheck all add-ons
|
160 |
+
}
|
161 |
+
|
162 |
function openModal(name, image2, description, price) {
|
163 |
const modal = document.getElementById('modal');
|
164 |
modal.style.display = 'block';
|
|
|
175 |
document.getElementById('special-instructions').value = '';
|
176 |
resetAddOns(); // Reset add-ons when opening the modal
|
177 |
}
|
178 |
+
|
179 |
function closeModal() {
|
180 |
document.getElementById('modal').style.display = 'none';
|
181 |
}
|
182 |
+
|
183 |
function addToCart() {
|
184 |
const name = document.getElementById('modal-name').innerText;
|
185 |
const price = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
|
|
|
193 |
}));
|
194 |
const extrasCost = extras.reduce((total, extra) => total + (extra.price * extra.quantity), 0);
|
195 |
const totalCost = (price * quantity) + extrasCost;
|
196 |
+
|
197 |
// Add the item to the cart with its specific add-ons
|
198 |
cart.push({ name, price, quantity, extras, instructions, totalCost });
|
199 |
totalCartCost += totalCost; // Update the total cost of the cart
|
|
|
201 |
updateCartTotalCost(); // Update total cost displayed
|
202 |
closeModal();
|
203 |
}
|
204 |
+
|
205 |
function updateCartButton() {
|
206 |
const cartButton = document.getElementById('cart-button');
|
207 |
cartButton.innerText = `View Cart (${cart.length} items)`;
|
208 |
}
|
209 |
+
|
210 |
function openCartModal() {
|
211 |
const cartModal = document.getElementById('cart-modal');
|
212 |
const cartItemsContainer = document.getElementById('cart-items');
|
|
|
226 |
});
|
227 |
cartModal.style.display = 'block';
|
228 |
}
|
229 |
+
|
230 |
function closeCartModal() {
|
231 |
document.getElementById('cart-modal').style.display = 'none';
|
232 |
}
|
233 |
+
|
234 |
function removeFromCart(index) {
|
235 |
totalCartCost -= cart[index].totalCost; // Deduct the cost of the removed item from total cost
|
236 |
cart.splice(index, 1);
|
|
|
238 |
updateCartTotalCost(); // Update total cost displayed
|
239 |
openCartModal();
|
240 |
}
|
241 |
+
|
242 |
function updateCartTotalCost() {
|
243 |
const totalCostElement = document.getElementById('cart-total-cost');
|
244 |
totalCartCost = cart.reduce((total, item) => total + item.totalCost, 0);
|
245 |
totalCostElement.innerText = `Total Cart Cost: $${totalCartCost.toFixed(2)}`;
|
246 |
}
|
247 |
+
|
248 |
function proceedToCheckout() {
|
249 |
const checkoutModal = document.getElementById('final-order-section');
|
250 |
let finalOrderHTML = "<h1>Final Order</h1>";
|