summaryrefslogtreecommitdiff
path: root/src-migrate/services
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/services')
-rw-r--r--src-migrate/services/cart.ts28
1 files changed, 20 insertions, 8 deletions
diff --git a/src-migrate/services/cart.ts b/src-migrate/services/cart.ts
index 73967073..11f87125 100644
--- a/src-migrate/services/cart.ts
+++ b/src-migrate/services/cart.ts
@@ -4,20 +4,32 @@ export const getUserCart = async (userId: number) => {
return await odooApi('GET', `/api/v1/user/${userId}/cart`);
};
-export const upsertUserCart = async (
- userId: number,
- type: 'product' | 'promotion',
- id: number,
- qty: number,
- selected: boolean,
- source: 'buy' | 'add_to_cart' = 'add_to_cart'
-) => {
+interface UpsertUserCartProps {
+ userId: number;
+ type: 'product' | 'promotion';
+ id: number;
+ qty: number;
+ selected: boolean;
+ source?: 'buy' | 'add_to_cart';
+ qtyAppend?: boolean;
+}
+
+export const upsertUserCart = async ({
+ userId,
+ type,
+ id,
+ qty,
+ selected,
+ source = 'add_to_cart',
+ qtyAppend = false,
+}: UpsertUserCartProps) => {
return await odooApi('POST', `/api/v1/user/${userId}/cart/create-or-update`, {
product_id: type === 'product' ? id : null,
qty,
selected,
program_line_id: type === 'promotion' ? id : null,
source,
+ qty_append: qtyAppend,
});
};