DSatishchandra commited on
Commit
e05cf65
·
verified ·
1 Parent(s): 61f1964

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +23 -7
templates/menu.html CHANGED
@@ -508,16 +508,23 @@ function addToCartFromModal() {
508
  const itemName = document.getElementById('modal-name').innerText;
509
  const itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
510
  const itemImage = document.getElementById('modal-img').src;
 
511
  const modalSectionEl = document.getElementById('modal-section');
512
  const section = modalSectionEl.getAttribute('data-section');
513
  const selectedCategory = modalSectionEl.getAttribute('data-category');
514
 
 
 
 
 
 
 
515
  // Collect selected add-ons
516
- const selectedAddOns = Array.from(
517
  document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
518
  ).map(addon => ({
519
- name: addon.getAttribute('data-name'),
520
- price: parseFloat(addon.getAttribute('data-price'))
521
  }));
522
 
523
  const instructions = document.getElementById('modal-instructions').value;
@@ -588,14 +595,23 @@ function updateCartDisplay(cart) {
588
  }, 2000);
589
  }
590
 
591
- // Function to round reward points to a single digit
592
- function roundRewardPoints() {
 
593
  let rewardPointsElement = document.getElementById('reward-points');
594
 
 
595
  if (rewardPointsElement) {
596
- let rewardPoints = parseFloat(rewardPointsElement.innerText);
 
 
 
 
 
597
  if (!isNaN(rewardPoints)) {
598
- rewardPointsElement.innerText = rewardPoints.toFixed(1); // Rounding to 1 decimal place
 
 
599
  }
600
  } else {
601
  console.error("Reward points element is missing.");
 
508
  const itemName = document.getElementById('modal-name').innerText;
509
  const itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
510
  const itemImage = document.getElementById('modal-img').src;
511
+ console.log(itemName, itemPrice, itemImage); // Log values for debugging
512
  const modalSectionEl = document.getElementById('modal-section');
513
  const section = modalSectionEl.getAttribute('data-section');
514
  const selectedCategory = modalSectionEl.getAttribute('data-category');
515
 
516
+ if (!itemName || !itemPrice || !section) {
517
+ console.error('Missing data for cart item:', { itemName, itemPrice, section });
518
+ return;
519
+ }
520
+
521
+
522
  // Collect selected add-ons
523
+ let selectedAddOns = Array.from(
524
  document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
525
  ).map(addon => ({
526
+ name: addon.getAttribute('data-name') || 'Default Name', //Fallback Name
527
+ price: parseFloat(addon.getAttribute('data-price') || 0)
528
  }));
529
 
530
  const instructions = document.getElementById('modal-instructions').value;
 
595
  }, 2000);
596
  }
597
 
598
+ // Function to round reward points to a single digit
599
+ function roundRewardPoints() {
600
+ // Get the reward points element
601
  let rewardPointsElement = document.getElementById('reward-points');
602
 
603
+ // Check if the element exists in the DOM
604
  if (rewardPointsElement) {
605
+ let rewardPointsText = rewardPointsElement.innerText.trim(); // Get and trim the value to remove any extra spaces
606
+
607
+ // Check if the innerText is a valid number
608
+ let rewardPoints = parseFloat(rewardPointsText);
609
+
610
+ // If it's a valid number, round it to 1 decimal place
611
  if (!isNaN(rewardPoints)) {
612
+ rewardPointsElement.innerText = rewardPoints.toFixed(1); // Round to 1 decimal place
613
+ } else {
614
+ console.error("Reward points value is not a valid number:", rewardPointsText);
615
  }
616
  } else {
617
  console.error("Reward points element is missing.");