Skip to content

Commit

Permalink
fix: cartprice
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya062003 committed Apr 9, 2024
1 parent 8e06cac commit 47dc3d0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions controllers/customerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ exports.getCartPrice = asyncHandler(async (req, res) => {

const restaurant = await Menu.findOne({ vendor_id: vendor_id });

if (!restaurant) {
return res.status(404).json({ error: "Restaurant not found" });
}
if (!restaurant) {
return res.status(404).json({ error: "Restaurant not found" });
}
Expand All @@ -139,17 +136,16 @@ exports.getCartPrice = asyncHandler(async (req, res) => {
return item.item_id === cartItem.id;
});

console.log(menuItem);

if (menuItem) {
totalPrice += menuItem.price * cartItem.quantity;
} else {
console.log("does not work");
const itemPrice = menuItem.on_offer
? menuItem.offer_price
: menuItem.price;
totalPrice += itemPrice * cartItem.quantity;
}
}
return res.json({ totalPrice });
} catch (error) {
return res.status(500).json({ error: error });
return res.status(500).json({ error: error.message });
}
});

Expand Down

0 comments on commit 47dc3d0

Please sign in to comment.