remotes/origin/mitri4
spacenergy 10 years ago
parent f56be13e7f
commit cdb02cba0b
  1. 10
      store/cart.py

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

Loading…
Cancel
Save