test: add unit tests for frontend top-down auto-reset and backend split logic
This commit is contained in:
17
shop/lib/checkout-split.ts
Normal file
17
shop/lib/checkout-split.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export interface CartItem {
|
||||
id?: string;
|
||||
billingInterval?: 'one_time' | 'monthly';
|
||||
billingType?: 'purchase' | 'subscription';
|
||||
selections: any;
|
||||
moduleQuantities?: Record<string, number>;
|
||||
}
|
||||
|
||||
export function splitCart(items: CartItem[]) {
|
||||
const purchaseItems = items.filter(
|
||||
item => item.billingInterval === 'one_time' || item.billingType === 'purchase'
|
||||
);
|
||||
const subscriptionItems = items.filter(
|
||||
item => item.billingInterval === 'monthly' || item.billingType === 'subscription'
|
||||
);
|
||||
return { purchaseItems, subscriptionItems };
|
||||
}
|
||||
Reference in New Issue
Block a user