Usando o cálculo do preço do Nodejs Cart
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
}
Cute Capybara