DSatishchandra commited on
Commit
4d445df
·
verified ·
1 Parent(s): 4c1d26b

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +10 -1
templates/menu.html CHANGED
@@ -269,6 +269,7 @@
269
  const addonsList = document.getElementById('addons-list');
270
  addonsList.innerHTML = ''; // Clear previous content
271
 
 
272
  if (!data.success || !data.addons || data.addons.length === 0) {
273
  addonsList.innerHTML = 'No add-ons available.';
274
  return;
@@ -296,8 +297,9 @@
296
  const selectedAddOns = Array.from(
297
  document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
298
  ).map(addon => addon.value);
 
299
 
300
- console.log("Add to cart payload:", { itemName, itemPrice, itemImage, selectedAddOns });
301
 
302
  if (!itemName || !itemPrice) {
303
  alert('Failed to add item to cart. Please try again.');
@@ -324,6 +326,13 @@
324
  if (data.success) {
325
  // Show a toast notification instead of redirecting
326
  showToast('Item added to cart successfully!');
 
 
 
 
 
 
 
327
  } else {
328
  console.error('Error adding item to cart:', data.error);
329
  alert(data.error || 'Failed to add item to cart.');
 
269
  const addonsList = document.getElementById('addons-list');
270
  addonsList.innerHTML = ''; // Clear previous content
271
 
272
+ // If no add-ons are available, display message
273
  if (!data.success || !data.addons || data.addons.length === 0) {
274
  addonsList.innerHTML = 'No add-ons available.';
275
  return;
 
297
  const selectedAddOns = Array.from(
298
  document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
299
  ).map(addon => addon.value);
300
+
301
 
302
+ //console.log("Add to cart payload:", { itemName, itemPrice, itemImage, selectedAddOns });
303
 
304
  if (!itemName || !itemPrice) {
305
  alert('Failed to add item to cart. Please try again.');
 
326
  if (data.success) {
327
  // Show a toast notification instead of redirecting
328
  showToast('Item added to cart successfully!');
329
+
330
+ //close the modal
331
+ const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
332
+ if (modal) {
333
+ modal.hide();
334
+ console.log("Modal closed");
335
+ }
336
  } else {
337
  console.error('Error adding item to cart:', data.error);
338
  alert(data.error || 'Failed to add item to cart.');