function goToCheckout(){
  if (checkoutButton.disabled) return;
  orderName = prompt("Digite o seu nome");
  orderAddress = prompt("Digite o seu endereco");
  checkoutScreen.classList.remove("d-none");

  const checkoutLines = document.querySelectorAll(".order-line");
  let priceCount = 0;
  for (let i=0; i<selectSectionIDs.length; i++){
    const firstP = checkoutLines[i].querySelector("p:first-child");
    const lastP = checkoutLines[i].querySelector("p:last-child");

    const selectedItem = document.querySelector(`#${selectSectionIDs[i]} .selected h3`);
    const item = selectedItem.textContent;
    firstP.textContent = item;

    const selectedPrice = document.querySelector(`#${selectSectionIDs[i]} .selected .unit-price`);
    const price = selectedPrice.textContent;
    lastP.textContent = price;

    let tempStr = price;
    tempStr = tempStr.replace("R$","").replace(" ", "").replace(",","");
    priceCount += parseInt(tempStr, 10);
  }

  const total = priceCount/100;
  const totalStr = "R$ " + total.toFixed(2).toString().replace(".",",");
  document.querySelector("#total").textContent = totalStr;
}
//if the order button is clicked
if the order button is clicked
if the order button is clicked
function goToCheckout(){
  if (checkoutButton.disabled) return;
  orderName = prompt("Digite o seu nome");
  orderAddress = prompt("Digite o seu endereco");
  checkoutScreen.classList.remove("d-none");
  const checkoutLines = document.querySelectorAll(".order-line");
  let priceCount = 0;
  for (let i=0; i<selectSectionIDs.length; i++){
    const firstP = checkoutLines[i].querySelector("p:first-child");
    const lastP = checkoutLines[i].querySelector("p:last-child");
    const selectedItem = document.querySelector(`#${selectSectionIDs[i]} .selected h3`);
    const item = selectedItem.textContent;
    firstP.textContent = item;
    const selectedPrice = document.querySelector(`#${selectSectionIDs[i]} .selected .unit-price`);
    const price = selectedPrice.textContent;
    lastP.textContent = price;
    let tempStr = price;
    tempStr = tempStr.replace("R$","").replace(" ", "").replace(",","");
    priceCount += parseInt(tempStr, 10);
  }
  const total = priceCount/100;
  const totalStr = "R$ " + total.toFixed(2).toString().replace(".",",");
  document.querySelector("#total").textContent = totalStr;
}
function goToCheckout ( ) { if ( checkoutButton . disabled ) return ; orderName = prompt ( "Digite o seu nome" ) ; orderAddress = prompt ( "Digite o seu endereco" ) ; checkoutScreen . classList . remove ( "d-none" ) ; const checkoutLines = document . querySelectorAll ( ".order-line" ) ; let priceCount = 0 ; for ( let i = 0 ; i < selectSectionIDs . length ; i ++ ) { const firstP = checkoutLines [ i ] . querySelector ( "p:first-child" ) ; const lastP = checkoutLines [ i ] . querySelector ( "p:last-child" ) ; const selectedItem = document . querySelector ( ` ${ selectSectionIDs [ i ] } ` ) ; const item = selectedItem . textContent ; firstP . textContent = item ; const selectedPrice = document . querySelector ( ` ${ selectSectionIDs [ i ] } ` ) ; const price = selectedPrice . textContent ; lastP . textContent = price ; let tempStr = price ; tempStr = tempStr . replace ( "R$" , "" ) . replace ( " " , "" ) . replace ( "," , "" ) ; priceCount += parseInt ( tempStr , 10 ) ; } const total = priceCount / 100 ; const totalStr = "R$ " + total . toFixed ( 2 ) . toString ( ) . replace ( "." , "," ) ; document . querySelector ( "#total" ) . textContent = totalStr ; }
if the order button is clicked
if the order button is clicked