cart place holder

This commit is contained in:
Parsa Nazer
2025-03-11 01:21:16 +03:30
parent 06b540d069
commit 4255910e81
2 changed files with 52 additions and 11 deletions
+17 -9
View File
@@ -74,17 +74,25 @@ class OrderModel(models.Model):
super().save(*args, **kwargs)
def discount_list(self):
items_with_discount = self.items.filter(product__discount__gt=0)
discount_amount_dict = {f'{item.product}': item.product.discount for item in items_with_discount}
if self.discount_code:
if self.discount_code.is_valid():
discount_amount_dict['discount_code_discount'] = 10
else:
self.discount = None
self.save()
return discount_amount_dict
def discount(self):
pass
# total_with_item_discount = sum(item.total_with_discount() for item in self.items.all())
# if self.discount_code:
# if not self.discount_code.is_valid():
# raise DiscountNotAvailableError('این کد تخفیف دیگر معتبر نیست')
# discount_percent = self.discount_code.percent
# return total_with_item_discount * ((100 - discount_percent) / 100)
# return total_with_item_discount
# return total_with_item_discount * ((100 - discount_percent) / 100)
# discount_percent = self.discount_code.percent
pass
def tax(self):
return self.total_without_tax() * 0.2