Beispiel #1
0
def add(request, product_key):
    postdata = request.POST.copy()
    quantity = int(postdata.get('quantity', 1))
    product = Product.get(product_key)
    item = CartItem.all().filter('product = ', product).filter('cart_id = ', get_cart_id(request)).get()
    if not item:
        item = CartItem()
        item.product = product
        item.quantity = quantity
        item.cart_id = get_cart_id(request)
        item.put()
    else:
        item.quantity = item.quantity + quantity
        item.put()
Beispiel #2
0
 def __init__(self, request):
     cart_id = get_cart_id(request)
     query = CartItem.all().filter('cart_id = ', cart_id)
     self.items = query.fetch(20)
     self.subtotal = Decimal('0.00')
     for item in self.items:
         self.subtotal += Decimal(str(item.total))
Beispiel #3
0
 def __init__(self, request):
     cart_id = get_cart_id(request)
     query = CartItem.all().filter('cart_id = ', cart_id)
     self.items = query.fetch(20)
     self.subtotal = Decimal('0.00')
     for item in self.items:
         self.subtotal += Decimal(str(item.total))
Beispiel #4
0
def update_item(item_key, quantity):
    key = db.Key(item_key)
    item = CartItem.get(key)
    if item:
        if quantity <= 0:
            item.delete()
        else:
            item.quantity = int(quantity)
            item.put()
Beispiel #5
0
def update_item(item_key, quantity):
    key = db.Key(item_key)
    item = CartItem.get(key)
    if item:
        if quantity <= 0:
            item.delete()
        else:
            item.quantity = int(quantity)
            item.put()
Beispiel #6
0
def remove_item(item_key):
    key = db.Key(item_key)
    item = CartItem.get(key)
    if item:
        item.delete()
Beispiel #7
0
def remove_item(item_key):
    key = db.Key(item_key)
    item = CartItem.get(key)
    if item:
        item.delete()
Beispiel #8
0
def add(request, product_key):
    postdata = request.POST.copy()
    quantity = int(postdata.get('quantity', 1))
    product = Product.get(product_key)
    item = CartItem.all().filter('product = ',
                                 product).filter('cart_id = ',
                                                 get_cart_id(request)).get()
    if not item:
        item = CartItem()
        item.product = product
        item.quantity = quantity
        item.cart_id = get_cart_id(request)
        item.put()
    else:
        item.quantity = item.quantity + quantity
        item.put()