feat(admin): move allow_update_discount option to product level
All checks were successful
Staging Build / build (push) Successful in 2m50s
All checks were successful
Staging Build / build (push) Successful in 2m50s
This commit is contained in:
@@ -183,11 +183,11 @@ export function buildOrderSnapshot(
|
||||
multiplier = 0.90
|
||||
}
|
||||
|
||||
// Multiply only one_time item totals by multiplier if category allows it
|
||||
// Multiply only one_time item totals by multiplier if product allows it
|
||||
items.forEach(item => {
|
||||
if (item.billing_interval === 'one_time') {
|
||||
const cat = categories.find(c => c.id === item.category_id);
|
||||
const allowDiscount = cat ? (cat as any).allow_update_discount !== false : true;
|
||||
const prod = products.find(p => p.id === item.product_id);
|
||||
const allowDiscount = prod ? prod.allow_update_discount !== false : true;
|
||||
if (allowDiscount) {
|
||||
item.item_total = item.item_total * multiplier;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ export type Product = {
|
||||
show_in_abo?: boolean
|
||||
requirements?: string[]
|
||||
exclusions?: string[]
|
||||
allow_update_discount?: boolean
|
||||
}
|
||||
|
||||
export type Category = {
|
||||
@@ -32,7 +33,6 @@ export type Category = {
|
||||
show_in_kauf?: boolean
|
||||
show_in_abo?: boolean
|
||||
resets_others: boolean
|
||||
allow_update_discount?: boolean
|
||||
created_at: string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user