diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-06-12 16:12:02 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-06-12 16:12:02 +0700 |
| commit | 626e93d3a0bfad2bc87002d9e0a7ae860ea9baba (patch) | |
| tree | dbc93f860cdec2308388fa43b10837bf29ab455f /indoteknik_api | |
| parent | 2bc522f12795bbd649d28fbc6f127df2ebac34ee (diff) | |
<hafid> fix pricelist product
Diffstat (limited to 'indoteknik_api')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/cart.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py index 7a40b1e2..fdc237cf 100644 --- a/indoteknik_api/controllers/api_v1/cart.py +++ b/indoteknik_api/controllers/api_v1/cart.py @@ -16,24 +16,31 @@ class Cart(controller.Controller): offset = int(kw.get('offset', 0)) query = [('user_id', '=', user_id)] carts = user_cart.search(query, limit=limit, offset=offset, order='create_date desc') - # carts.write({'source': 'add_to_cart'}) + products = [] 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.append(product_active) + try: + 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.append(product_active) + else: + product_inactives = cart.with_context(price_for="web").get_products() + for inactives in product_inactives: + products_inactive.append(inactives) 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.append(programs) + program = cart.with_context(price_for="web").get_products() + for programs in program: + products.append(programs) + + except Exception as e: + continue + data = { 'product_total': user_cart.search_count(query), 'products': products, |
