feat: support product quantity and separate steps
All checks were successful
Staging Build / build (push) Successful in 6m17s
All checks were successful
Staging Build / build (push) Successful in 6m17s
This commit is contained in:
@@ -91,7 +91,8 @@ export function buildOrderSnapshot(
|
||||
categories: Category[],
|
||||
billingInterval?: 'one_time' | 'monthly',
|
||||
moduleQuantities?: Record<string, number>,
|
||||
lastLicenseDate?: string | null
|
||||
lastLicenseDate?: string | null,
|
||||
productQuantities?: Record<string, number>
|
||||
): OrderSnapshot {
|
||||
const items: OrderItem[] = []
|
||||
let subtotal = 0
|
||||
@@ -135,11 +136,12 @@ export function buildOrderSnapshot(
|
||||
}
|
||||
})
|
||||
|
||||
const productQty = productQuantities?.[prod.id] || 1
|
||||
const moduleTotal = selectedModules.reduce((acc, m) => acc + (m.total_price || m.price), 0)
|
||||
|
||||
// If this product falls under the free limit, set its base price to 0
|
||||
const actualBasePrice = (sortedIndex < freeLimit) ? 0 : prod.base_price
|
||||
const itemTotal = actualBasePrice + moduleTotal
|
||||
const itemTotal = (actualBasePrice + moduleTotal) * productQty
|
||||
subtotal += itemTotal
|
||||
|
||||
items.push({
|
||||
@@ -149,6 +151,7 @@ export function buildOrderSnapshot(
|
||||
product_name: prod.name + (actualBasePrice === 0 ? " (Inklusive/Frei)" : ""),
|
||||
base_price: actualBasePrice,
|
||||
billing_interval: prod.billing_interval,
|
||||
quantity: productQty,
|
||||
selected_modules: selectedModules,
|
||||
item_total: itemTotal,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user