Subversion Repositories SmartDukaan

Rev

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

Rev 1341 Rev 1466
Line 270... Line 270...
270
    return t_line_item
270
    return t_line_item
271
    
271
    
272
def validate_cart(cartId):
272
def validate_cart(cartId):
273
    inventory_client = InventoryClient().get_client()
273
    inventory_client = InventoryClient().get_client()
274
    logistics_client = LogisticsClient().get_client()
274
    logistics_client = LogisticsClient().get_client()
275
    retval = True
275
    retval = ""
276
    # No need to validate duplicate items since there are only two ways
276
    # No need to validate duplicate items since there are only two ways
277
    # to add items to a cart and both of them check whether the item being
277
    # to add items to a cart and both of them check whether the item being
278
    # added is a duplicate of an already existing item.
278
    # added is a duplicate of an already existing item.
279
    cart = Cart.get_by(id=cartId)
279
    cart = Cart.get_by(id=cartId)
280
    cart_lines = cart.lines
280
    cart_lines = cart.lines
Line 304... Line 304...
304
            except :
304
            except :
305
                item_delivery_estimate = -1
305
                item_delivery_estimate = -1
306
            if old_estimate != item_delivery_estimate:
306
            if old_estimate != item_delivery_estimate:
307
                line.estimate = item_delivery_estimate
307
                line.estimate = item_delivery_estimate
308
                cart.updated_on = current_time
308
                cart.updated_on = current_time
309
                retval = False
309
                if old_estimate != None:
-
 
310
                    retval = "Delivery Estimates updated."
310
        else:
311
        else:
311
            line.delete()
312
            line.delete()
312
            retval = False
313
            retval = "Some items have been removed from the cart."
313
    if cart.checked_out_on is not None:
314
    if cart.checked_out_on is not None:
314
        if cart.updated_on > cart.checked_out_on:
315
        if cart.updated_on > cart.checked_out_on:
315
            cart.checked_out_on = None
316
            cart.checked_out_on = None
316
            retval = False
317
            if retval == "":
-
 
318
                retval = "Your cart has been updated after the last checkout."
317
    session.commit()
319
    session.commit()
318
    return retval
320
    return retval
319
 
321
 
320
def merge_cart(fromCartId, toCartId):
322
def merge_cart(fromCartId, toCartId):
321
    fromCart = Cart.get_by(id=fromCartId)
323
    fromCart = Cart.get_by(id=fromCartId)