Subversion Repositories SmartDukaan

Rev

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

Rev 11819 Rev 11853
Line 202... Line 202...
202
def apply_coupon_to_cart(t_cart, coupon_code):
202
def apply_coupon_to_cart(t_cart, coupon_code):
203
    cart = get_cart_by_id(t_cart.id)
203
    cart = get_cart_by_id(t_cart.id)
204
    if not cart:
204
    if not cart:
205
        raise ShoppingCartException(101, "no cart attached to this id")
205
        raise ShoppingCartException(101, "no cart attached to this id")
206
    pc = PromotionClient().get_client()
206
    pc = PromotionClient().get_client()
207
    if not pc.isGiftVoucher(coupon_code):
-
 
208
        for t_line in t_cart.lines:
207
    for t_line in t_cart.lines:
209
            line = Line.query.filter_by(cart = cart).filter_by(item_id = t_line.itemId).one()
208
        line = Line.query.filter_by(cart = cart).filter_by(item_id = t_line.itemId).one()
210
        #Update its discounted price.
209
        if not pc.isGiftVoucher(coupon_code):
211
            line.discounted_price = t_line.discountedPrice
210
            line.discounted_price = t_line.discountedPrice
212
            line.dealText = t_line.dealText
211
        line.dealText = t_line.dealText
213
            line.freebieId = t_line.freebieId
212
        line.freebieId = t_line.freebieId
214
    
213
    
215
    cart.total_price = t_cart.totalPrice
214
    cart.total_price = t_cart.totalPrice
216
    cart.discounted_price = t_cart.discountedPrice
215
    cart.discounted_price = t_cart.discountedPrice
217
    cart.coupon_code = coupon_code
216
    cart.coupon_code = coupon_code
218
    session.commit()
217
    session.commit()