From a13be65796e8dd5dc164b516c74522263ef4945a Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 10:22:02 +0100 Subject: [PATCH] Fix: use personalised pricing for items with design elements at checkout --- src/app/api/checkout/route.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/api/checkout/route.ts b/src/app/api/checkout/route.ts index c758652..427878f 100644 --- a/src/app/api/checkout/route.ts +++ b/src/app/api/checkout/route.ts @@ -75,10 +75,14 @@ export async function POST(req: Request) { } const activePromotions = await fetchActivePromotions(); - const pricedItems = items.map((i) => ({ - ...i, - unitPrice: getEffectivePrice(productsById.get(i.productId)!, activePromotions).price, - })); + const pricedItems = items.map((i) => { + const design = i.designJson as { front: unknown[]; back: unknown[] }; + const isPersonalised = design.front.length > 0 || design.back.length > 0; + return { + ...i, + unitPrice: getEffectivePrice(productsById.get(i.productId)!, activePromotions, new Date(), isPersonalised).price, + }; + }); const total = pricedItems.reduce((sum, i) => sum + i.unitPrice * i.quantity, 0); const customer = await getCurrentCustomer();