|
|
|
|
@ -5,11 +5,11 @@ import uuid |
|
|
|
|
class CartItem(object): |
|
|
|
|
subtotal = 0 |
|
|
|
|
|
|
|
|
|
def __init__(self, item_variant, count, id=None): |
|
|
|
|
def __init__(self, item_variant, count, id=None, request=None): |
|
|
|
|
self.item = item_variant |
|
|
|
|
self.price = int(item_variant.get_price()) |
|
|
|
|
self.price = int(item_variant.get_price(request.user)) |
|
|
|
|
self.count = int(count) |
|
|
|
|
self.subtotal = self.get_price() * self.count |
|
|
|
|
self.subtotal = self.get_price(request.user) * self.count |
|
|
|
|
|
|
|
|
|
if not id: |
|
|
|
|
self.id = str(uuid.uuid4()) |
|
|
|
|
@ -49,7 +49,7 @@ class Cart(object): |
|
|
|
|
pass |
|
|
|
|
if variation: |
|
|
|
|
item = CartItem( |
|
|
|
|
variation, j['count'], j['id']) |
|
|
|
|
variation, j['count'], j['id'], request=self.request) |
|
|
|
|
self.items.append(item) |
|
|
|
|
self.total += int(item.subtotal) |
|
|
|
|
self.weight += variation.weight * j['count'] |
|
|
|
|
@ -97,7 +97,7 @@ class Cart(object): |
|
|
|
|
if item.count != request_count: |
|
|
|
|
self.total -= item.subtotal |
|
|
|
|
item.count = request_count |
|
|
|
|
item.subtotal = item.get_price() * item.count |
|
|
|
|
item.subtotal = item.get_price(self.request) * item.count |
|
|
|
|
self.total += item.subtotal |
|
|
|
|
self.serialize_items() |
|
|
|
|
|
|
|
|
|
|