Skip to content

Commit 935d682

Browse files
committed
Merge pull request bmentges#2 from dfalk/master
Method for items count and items summary added by dfalk. Thanks again dfalk. :)
2 parents a578210 + f959051 commit 935d682

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cart/cart.py

+12
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ def update(self, product, quantity, unit_price=None):
6868
)
6969
except models.Item.DoesNotExist:
7070
raise ItemDoesNotExist
71+
72+
def count(self):
73+
result = 0
74+
for item in self.cart.item_set.all():
75+
result += 1 * item.quantity
76+
return result
77+
78+
def summary(self):
79+
result = 0
80+
for item in self.cart.item_set.all():
81+
result += item.total_price
82+
return result
7183

7284
def clear(self):
7385
for item in self.cart.item_set.all():

0 commit comments

Comments
 (0)