DSatishchandra commited on
Commit
0998962
·
verified ·
1 Parent(s): 53c7c69

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +38 -38
templates/menu.html CHANGED
@@ -406,45 +406,45 @@
406
  modalSectionEl.setAttribute('data-category', selectedCategory);
407
  // Fetch customization options based on the section
408
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
409
- .then(response => response.json())
410
- .then(data => {
411
- const addonsList = document.getElementById('addons-list');
412
- addonsList.innerHTML = ''; // Clear previous content
413
-
414
- if (!data.success || !data.addons || data.addons.length === 0) {
415
- addonsList.innerHTML = '<p>No customization options available.</p>';
416
- return;
417
- }
418
- // Display customization options inside styled divs
419
- data.addons.forEach(addon => {
420
- const sectionDiv = document.createElement('div');
421
- sectionDiv.classList.add('addon-section'); // Add styling class
422
- // Add section title
423
- const title = document.createElement('h6');
424
- title.innerText = addon.name;
425
- sectionDiv.appendChild(title);
426
- // Create options list
427
- const optionsContainer = document.createElement('div');
428
- addon.options.forEach((option, index) => {
429
- const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
430
- const listItem = document.createElement('div');
431
- listItem.classList.add('form-check');
432
- listItem.innerHTML = `
433
- <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
434
- data-name="${option}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
435
- <label class="form-check-label" for="${optionId}">${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}</label>
436
- `;
437
- optionsContainer.appendChild(listItem);
438
- });
439
- sectionDiv.appendChild(optionsContainer);
440
- addonsList.appendChild(sectionDiv);
441
- });
442
- })
443
- .catch(err => {
444
- console.error('Error fetching add-ons:', err);
445
- document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
446
- });
447
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
 
449
  function addToCartFromModal() {
450
  const itemName = document.getElementById('modal-name').innerText;
 
406
  modalSectionEl.setAttribute('data-category', selectedCategory);
407
  // Fetch customization options based on the section
408
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
409
+ .then(response => response.json())
410
+ .then(data => {
411
+ const addonsList = document.getElementById('addons-list');
412
+ addonsList.innerHTML = ''; // Clear previous content
413
+
414
+ if (!data.success || !data.addons || data.addons.length === 0) {
415
+ addonsList.innerHTML = '<p>No customization options available.</p>';
416
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  }
418
+
419
+ data.addons.forEach(addon => {
420
+ const sectionDiv = document.createElement('div');
421
+ sectionDiv.classList.add('addon-section');
422
+ const title = document.createElement('h6');
423
+ title.innerText = addon.name;
424
+ sectionDiv.appendChild(title);
425
+
426
+ const optionsContainer = document.createElement('div');
427
+ addon.options.forEach((option, index) => {
428
+ const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
429
+ const listItem = document.createElement('div');
430
+ listItem.classList.add('form-check');
431
+ listItem.innerHTML = `
432
+ <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
433
+ data-name="${option}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
434
+ <label class="form-check-label" for="${optionId}">
435
+ ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
436
+ </label>
437
+ `;
438
+ optionsContainer.appendChild(listItem);
439
+ });
440
+ sectionDiv.appendChild(optionsContainer);
441
+ addonsList.appendChild(sectionDiv);
442
+ });
443
+ })
444
+ .catch(err => {
445
+ console.error('Error fetching add-ons:', err);
446
+ document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
447
+ });
448
 
449
  function addToCartFromModal() {
450
  const itemName = document.getElementById('modal-name').innerText;