diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-11-06 06:03:52 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-11-06 06:03:52 +0000 |
| commit | cc41d4946f021f29c94c342c9b11606e78719673 (patch) | |
| tree | b4d9d0ce3296614e56afb94a40e0c002618870f1 /indoteknik_api/controllers/api_v1 | |
| parent | 3a818abaab201a82bbba6736adb83c26958338d2 (diff) | |
| parent | 4a3ff9e6fc85f534c106198c0ceee4e8c33eba5c (diff) | |
Merged in BF/products-inactive (pull request #248)
<iman> update bug products_inactive on user carts
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/cart.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py index 2a24b205..7a40b1e2 100644 --- a/indoteknik_api/controllers/api_v1/cart.py +++ b/indoteknik_api/controllers/api_v1/cart.py @@ -46,8 +46,25 @@ class Cart(controller.Controller): def get_cart_count_by_user_id(self, user_id, **kw): user_id = int(user_id) query = [('user_id', '=', user_id)] - carts = request.env['website.user.cart'].search_count(query) - return self.response(carts) + carts = request.env['website.user.cart'].search(query) + products_active = [] + products_inactive = [] + for cart in carts: + if cart.product_id: + price = cart.product_id._v2_get_website_price_include_tax() + if cart.product_id.active and price > 0: + product = cart.with_context(price_for="web").get_products() + for product_active in product: + products_active.append(product_active) + else: + product_inactives = cart.with_context(price_for="web").get_products() + for inactives in product_inactives: + products_inactive.append(inactives) + else: + program = cart.with_context(price_for="web").get_products() + for programs in program: + products_active.append(programs) + return self.response(len(products_active)) @http.route(PREFIX_USER + 'cart/create-or-update', auth='public', methods=['POST', 'OPTIONS'], csrf=False) @controller.Controller.must_authorized(private=True, private_key='user_id') |
