Update templates/menu.html
Browse files- templates/menu.html +63 -82
templates/menu.html
CHANGED
@@ -592,90 +592,71 @@ form-check-input addon-option{
|
|
592 |
<!-- JavaScript -->
|
593 |
<script>
|
594 |
// Show item details and fetch customization options
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
.
|
599 |
-
.
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
title.innerText = addon.name;
|
644 |
-
sectionDiv.appendChild(title);
|
645 |
-
|
646 |
-
// Create options list
|
647 |
-
const optionsContainer = document.createElement('div');
|
648 |
-
addon.options.forEach((option, index) => {
|
649 |
-
const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
|
650 |
-
const listItem = document.createElement('div');
|
651 |
-
listItem.classList.add('form-check');
|
652 |
-
|
653 |
-
// Check if this option was selected before
|
654 |
-
const checked = previousItem.addons.includes(option); // Pre-select based on previous addons
|
655 |
-
|
656 |
-
listItem.innerHTML = `
|
657 |
-
<input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}" ${checked ? 'checked' : ''}
|
658 |
-
data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
|
659 |
-
<label class="form-check-label" for="${optionId}">
|
660 |
-
${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
|
661 |
-
</label>
|
662 |
-
`;
|
663 |
-
optionsContainer.appendChild(listItem);
|
664 |
-
});
|
665 |
-
|
666 |
-
sectionDiv.appendChild(optionsContainer);
|
667 |
-
addonsList.appendChild(sectionDiv);
|
668 |
});
|
669 |
-
|
670 |
-
|
671 |
-
console.error('Error fetching add-ons:', err);
|
672 |
-
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
673 |
});
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
|
680 |
function handleToggle(source) {
|
681 |
const form = document.getElementById("filter-form");
|
|
|
592 |
<!-- JavaScript -->
|
593 |
<script>
|
594 |
// Show item details and fetch customization options
|
595 |
+
function showItemDetails(name, price, image, description, section, selectedCategory) {
|
596 |
+
document.getElementById('modal-name').innerText = name;
|
597 |
+
document.getElementById('modal-price').innerText = `$${price}`;
|
598 |
+
document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
|
599 |
+
document.getElementById('modal-description').innerText = description || 'No description available.';
|
600 |
+
document.getElementById('addons-list').innerHTML = 'Loading customization options...';
|
601 |
+
document.getElementById('modal-instructions').value = '';
|
602 |
+
const modalSectionEl = document.getElementById('modal-section');
|
603 |
+
modalSectionEl.setAttribute('data-section', section);
|
604 |
+
modalSectionEl.setAttribute('data-category', selectedCategory);
|
605 |
+
// Set the default quantity to 1
|
606 |
+
document.getElementById('quantityInput').value = 1;
|
607 |
+
|
608 |
+
// Fetch customization options based on the section
|
609 |
+
fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
|
610 |
+
.then(response => response.json())
|
611 |
+
.then(data => {
|
612 |
+
const addonsList = document.getElementById('addons-list');
|
613 |
+
addonsList.innerHTML = ''; // Clear previous content
|
614 |
+
if (!data.success || !data.addons || data.addons.length === 0) {
|
615 |
+
addonsList.innerHTML = '<p>No customization options available.</p>';
|
616 |
+
return;
|
617 |
+
}
|
618 |
+
|
619 |
+
// Display customization options inside styled divs
|
620 |
+
data.addons.forEach(addon => {
|
621 |
+
const sectionDiv = document.createElement('div');
|
622 |
+
sectionDiv.classList.add('addon-section'); // Add styling class
|
623 |
+
|
624 |
+
// Add section title
|
625 |
+
const title = document.createElement('h6');
|
626 |
+
title.innerText = addon.name;
|
627 |
+
sectionDiv.appendChild(title);
|
628 |
+
|
629 |
+
// Create options list
|
630 |
+
const optionsContainer = document.createElement('div');
|
631 |
+
addon.options.forEach((option, index) => {
|
632 |
+
const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
|
633 |
+
const listItem = document.createElement('div');
|
634 |
+
listItem.classList.add('form-check');
|
635 |
+
listItem.innerHTML = `
|
636 |
+
<input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
|
637 |
+
data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
|
638 |
+
<label class="form-check-label" for="${optionId}">
|
639 |
+
${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
|
640 |
+
</label>
|
641 |
+
`;
|
642 |
+
optionsContainer.appendChild(listItem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
643 |
});
|
644 |
+
sectionDiv.appendChild(optionsContainer);
|
645 |
+
addonsList.appendChild(sectionDiv);
|
|
|
|
|
646 |
});
|
647 |
+
})
|
648 |
+
.catch(err => {
|
649 |
+
console.error('Error fetching add-ons:', err);
|
650 |
+
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
651 |
+
});
|
652 |
+
}
|
653 |
+
along with it we are storing details like # Store all order details (before deleting cart items)
|
654 |
+
order_details = "\n".join(
|
655 |
+
f"{item['Name']} x{item['Quantity__c']} | Add-Ons: {item.get('Add_Ons__c', 'None')} | "
|
656 |
+
f"Instructions: {item.get('Instructions__c', 'None')} | "
|
657 |
+
f"Price: ${item['Price__c']} | Image: {item['Image1__c']}"
|
658 |
+
for item in cart_items
|
659 |
+
)
|
660 |
|
661 |
function handleToggle(source) {
|
662 |
const form = document.getElementById("filter-form");
|