From 934079fc429e30f2412efea50f2ff35230260454 Mon Sep 17 00:00:00 2001 From: S Ray Date: Tue, 23 Jan 2024 20:46:04 +0100 Subject: [PATCH] Update dbOrderItems The previous code applies the same price for all products. --- app/api/orders/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/orders/route.ts b/app/api/orders/route.ts index a90b5a0..33481f9 100644 --- a/app/api/orders/route.ts +++ b/app/api/orders/route.ts @@ -40,7 +40,7 @@ export const POST = auth(async (req: any) => { const dbOrderItems = payload.items.map((x: { _id: string }) => ({ ...x, product: x._id, - price: dbProductPrices.find((x) => x._id === x._id).price, + price: dbProductPrices.find((item) => item._id.toString() === x._id).price, _id: undefined, }))