cart place holder
This commit is contained in:
+17
-9
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user