summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2024-11-07 13:47:35 +0700
committerstephanchrst <stephanchrst@gmail.com>2024-11-07 13:47:35 +0700
commit0e87cd50902756c86c975505a7dde2239d94968c (patch)
tree3d2d4daddba283a9c1cc0e3e97266eb400433cea
parent12393ab22afa2b5bace5243d68b13906d5a1a54f (diff)
bug fix wrong price in website user cart
-rw-r--r--indoteknik_custom/models/website_user_cart.py41
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..2142dada 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 and 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)