From db98ba79a92ca11df958cce513bc320110764434 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 26 Feb 2024 15:10:47 +0700 Subject: Add qty append on upsert cart api --- indoteknik_api/controllers/api_v1/cart.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py index 5948a277..f472a9b0 100644 --- a/indoteknik_api/controllers/api_v1/cart.py +++ b/indoteknik_api/controllers/api_v1/cart.py @@ -44,6 +44,7 @@ class Cart(controller.Controller): qty = int(kw.get('qty', 0)) source = kw.get('source') + qty_append = kw.get('qty_append', False) is_selected = kw.get('selected', False) is_selected = is_selected in ('true', True) @@ -78,6 +79,9 @@ class Cart(controller.Controller): 'product_id': product_id, 'source': source or False } + + if isinstance(qty_append, str) and qty_append.lower() == "true" and cart: + data_to_update['qty'] += cart.qty if cart: cart.write(data_to_update) -- cgit v1.2.3