update cart logic

This commit is contained in:
Parsa Nazer
2025-09-23 10:17:19 +03:30
parent cd6c5bf343
commit dab89b93a7
13 changed files with 469 additions and 153 deletions
+12
View File
@@ -302,6 +302,18 @@ class ProductVariant(models.Model):
def __str__(self):
return f"{self.product.name} - {', '.join(str(attr) for attr in self.product_attributes.all())}"
@property
def price_before_discount(self):
return self.price
@property
def price_after_discount(self):
return self.price * (self.discount / 100)
@property
def discount_amount(self):
return self.price * (self.discount / 100)
def set_or_update_price(self, dollor_price=None):
if not dollor_price:
dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique')