Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

using nodejs cart price calculation

async (req, res) => {
      let total = 0;
      let size_price = 0;
      let options_price = 0;
      
      let {
        items,
        tip,
      } = req.body;

      let price = 0;
      await Promise.all(items.map(async (el) => {
          let menu_item = await req.models.menu_item.findOne({ _id: el.id });
          price += parseInt(menu_item.price);
          console.log(menu_item.price) // first 12 second 9
          console.log(price) // first 12 second 21
        })
      );
      

      console.log(price) // return 0
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nodejs #cart #price #calculation
ADD COMMENT
Topic
Name
8+5 =