Subversion Repositories SmartDukaan

Rev

Rev 2219 | Rev 2815 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2219 Rev 2261
Line 193... Line 193...
193
 
193
 
194
def remove_coupon(cart_id):
194
def remove_coupon(cart_id):
195
    cart = get_cart_by_id(cart_id)
195
    cart = get_cart_by_id(cart_id)
196
    if not cart:
196
    if not cart:
197
        raise ShoppingCartException(101, "no cart attached to this id")
197
        raise ShoppingCartException(101, "no cart attached to this id")
-
 
198
    
-
 
199
    #Resetting discounted price of each line in cart to Null
-
 
200
    for line in cart.lines:
-
 
201
        line.discounted_price = None
-
 
202
    
198
    cart.discounted_price = None
203
    cart.discounted_price = None
199
    cart.coupon_code = None
204
    cart.coupon_code = None
200
    session.commit()
205
    session.commit()
201
    
206
    
202
def commit_cart(cart_id):   
207
def commit_cart(cart_id):   
Line 408... Line 413...
408
    if cartId is None:
413
    if cartId is None:
409
        raise ShoppingCartException(101, "Cart id not specified")
414
        raise ShoppingCartException(101, "Cart id not specified")
410
    for item_id, quantity in items.iteritems():
415
    for item_id, quantity in items.iteritems():
411
        line = Line.query.filter_by(cart_id=cartId, item_id=item_id).one()
416
        line = Line.query.filter_by(cart_id=cartId, item_id=item_id).one()
412
        if line is not None:
417
        if line is not None:
-
 
418
            line.discounted_price = None
413
            line.quantity = line.quantity - quantity
419
            line.quantity = line.quantity - quantity
414
            if line.quantity == 0:
420
            if line.quantity == 0:
415
                line.delete()
421
                line.delete()
416
    cart = Cart.get_by(id=cartId)
422
    cart = Cart.get_by(id=cartId)
417
    cart.updated_on = datetime.datetime.now()
423
    cart.updated_on = datetime.datetime.now()