From a3c5a66d3fa8d4d887d757fab29629874ee6c4d6 Mon Sep 17 00:00:00 2001 From: DanielS Date: Fri, 10 Jul 2026 00:18:23 +0200 Subject: [PATCH] feat: check category eligibility for update discount in frontend and backend --- shop/components/order-wizard.tsx | 8 +++----- shop/lib/license-transform.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/shop/components/order-wizard.tsx b/shop/components/order-wizard.tsx index 062dce1..4b7a45f 100644 --- a/shop/components/order-wizard.tsx +++ b/shop/components/order-wizard.tsx @@ -353,16 +353,14 @@ export function OrderWizard({ }) const totalItem = base + modulesSum if (prod.billing_interval === 'one_time') { - oneTime += totalItem + const allowDiscount = (cat as any).allow_update_discount !== false + const finalItemTotal = allowDiscount ? (totalItem * updatePriceModifier.multiplier) : totalItem + oneTime += finalItemTotal } else { monthly += totalItem } }) } - // Apply update modifier to oneTime total - if (updatePriceModifier.multiplier !== 1) { - oneTime = oneTime * updatePriceModifier.multiplier - } return { monthlyTotal: monthly, oneTimeTotal: oneTime } }, [selections, products, categories, moduleQuantities, updatePriceModifier]) diff --git a/shop/lib/license-transform.ts b/shop/lib/license-transform.ts index 66fb480..55dda61 100644 --- a/shop/lib/license-transform.ts +++ b/shop/lib/license-transform.ts @@ -183,10 +183,14 @@ export function buildOrderSnapshot( multiplier = 0.90 } - // Multiply only one_time item totals by multiplier + // Multiply only one_time item totals by multiplier if category allows it items.forEach(item => { if (item.billing_interval === 'one_time') { - item.item_total = item.item_total * multiplier + const cat = categories.find(c => c.id === item.category_id); + const allowDiscount = cat ? (cat as any).allow_update_discount !== false : true; + if (allowDiscount) { + item.item_total = item.item_total * multiplier; + } } }) subtotal = items.reduce((acc, item) => acc + item.item_total, 0)