1. Kai Diefenbach
  2. django-lfs

Commits

Kai Diefenbach  committed b4f4fd4

Added price / tax methods to cart.

  • Participants
  • Parent commits 8e3d789
  • Branches default

Comments (0)

Files changed (1)

File lfs/cart/models.py

View file
 from django.utils.translation import ugettext_lazy as _
 
 # lfs imports
+import lfs.cart.utils
 from lfs.catalog.models import Product
 
 class Cart(models.Model):
         cart_name.strip(', ')
         return cart_name
 
+    def get_price_gross(self):
+        """Returns the total gross price of all items.
+        """
+        price = 0
+        for item in self.items.all():
+            price += item.get_price_gross()
+
+        return price
+
+    def get_price_net(self):
+        """Returns the total net price of all items.
+        """
+        price = 0
+        for item in self.items.all():
+            price += item.get_price_net()
+
+        return price
+        
+    def get_tax(self):
+        """Returns the total tax of all items
+        """
+        tax = 0
+        for item in self.items.all():
+            tax += item.get_tax()
+
+        return tax
+
+
 class CartItem(models.Model):
     """A cart item belongs to a cart. It stores the product and the amount of
     the product which has been taken into the cart.