diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-11-11 14:11:42 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-11-11 14:11:42 +0700 |
| commit | fd6b9b5395b04135d9f0afdc0859fb4f07d280b4 (patch) | |
| tree | be6e7a4f201b949a3b06e0c020c668ba2b0730fa /indoteknik_custom/models/website_user_cart.py | |
| parent | f787f06a341f1775151d98be4490fe6126c511cd (diff) | |
| parent | 9a0fd25e54491bd14a5b29b62b31a440dfa1bebc (diff) | |
Merge branch 'production' into feature/max_plafon_order_qty
Diffstat (limited to 'indoteknik_custom/models/website_user_cart.py')
| -rw-r--r-- | indoteknik_custom/models/website_user_cart.py | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index fbcb0aa4..6cb282f8 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -93,45 +93,32 @@ class WebsiteUserCart(models.Model): def get_product_by_user(self, user_id, selected=False, source=False): user_id = int(user_id) - + if source == 'buy': source = ['buy'] else: source = ['add_to_cart', 'buy'] parameters = [ - ('user_id', '=', user_id), + ('user_id', '=', user_id), ('source', 'in', source) ] - - if selected: - parameters.append(('is_selected', '=', True)) - carts = self.search(parameters) - 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) - data = { - 'product_total': self.search_count(parameters), - 'products': products_active, - 'products_inactive': products_inactive - } - products = carts.get_products() - return products_active + if not cart.product_id.active or price < 1: + cart.is_selected = False + + if selected: + parameters.append(('is_selected', '=', True)) + + products_active = self.search(parameters) + + products = products_active.get_products() + + return products def get_user_checkout(self, user_id, voucher=False, voucher_shipping=False, source=False): products = self.get_product_by_user(user_id=user_id, selected=True, source=source) |
