function handleSelection(itemClass){
  let optionSelected = document.querySelector(itemClass);

  let currentMenu = optionSelected;
  while (!currentMenu.classList.contains("menu")){
    currentMenu = currentMenu.parentNode;
  }

  const currentSelected = currentMenu.querySelector(".selected");

  let checky;

  if (optionSelected === currentSelected){
    currentSelected.classList.remove("selected");
    checky = currentSelected.querySelector(".checked");
    checky.classList.add("d-none");
    updateCheckoutStatus();
    return;
  }

  if (currentSelected !== null){
    currentSelected.classList.remove("selected");
    checky = currentSelected.querySelector(".checked");
    checky.classList.add("d-none");
  }

  optionSelected.classList.add("selected");
  checky = optionSelected.querySelector(".checked");
  checky.classList.remove("d-none");
  
  updateCheckoutStatus();
}
//if needed and then updates the checkoutstatus
if needed and then updates the checkoutstatus
if needed and then updates the checkoutstatus
function handleSelection(itemClass){
  let optionSelected = document.querySelector(itemClass);
  let currentMenu = optionSelected;
  while (!currentMenu.classList.contains("menu")){
    currentMenu = currentMenu.parentNode;
  }
  const currentSelected = currentMenu.querySelector(".selected");
  let checky;
  if (optionSelected === currentSelected){
    currentSelected.classList.remove("selected");
    checky = currentSelected.querySelector(".checked");
    checky.classList.add("d-none");
    updateCheckoutStatus();
    return;
  }
  if (currentSelected !== null){
    currentSelected.classList.remove("selected");
    checky = currentSelected.querySelector(".checked");
    checky.classList.add("d-none");
  }
  optionSelected.classList.add("selected");
  checky = optionSelected.querySelector(".checked");
  checky.classList.remove("d-none");
  updateCheckoutStatus();
}
function handleSelection ( itemClass ) { let optionSelected = document . querySelector ( itemClass ) ; let currentMenu = optionSelected ; while ( ! currentMenu . classList . contains ( "menu" ) ) { currentMenu = currentMenu . parentNode ; } const currentSelected = currentMenu . querySelector ( ".selected" ) ; let checky ; if ( optionSelected === currentSelected ) { currentSelected . classList . remove ( "selected" ) ; checky = currentSelected . querySelector ( ".checked" ) ; checky . classList . add ( "d-none" ) ; updateCheckoutStatus ( ) ; return ; } if ( currentSelected !== null ) { currentSelected . classList . remove ( "selected" ) ; checky = currentSelected . querySelector ( ".checked" ) ; checky . classList . add ( "d-none" ) ; } optionSelected . classList . add ( "selected" ) ; checky = optionSelected . querySelector ( ".checked" ) ; checky . classList . remove ( "d-none" ) ; updateCheckoutStatus ( ) ; }
if needed and then updates the checkoutstatus
if needed and then updates the checkoutstatus