Subversion Repositories SmartDukaan

Rev

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

Rev 2186 Rev 2240
Line 19... Line 19...
19
def reset_cart(transaction, userServiceClient):
19
def reset_cart(transaction, userServiceClient):
20
    items = {}
20
    items = {}
21
    for order in transaction.orders:
21
    for order in transaction.orders:
22
        for line_item in order.lineitems:
22
        for line_item in order.lineitems:
23
            item_id = line_item.item_id
23
            item_id = line_item.item_id
24
            quantity = items[item_id]
24
            if items.has_key(item_id):
25
            if quantity is None:
-
 
26
                quantity = line_item.quantity
25
                quantity = items[item_id] + line_item.quantity
27
            else:
26
            else:
28
                quantity = quantity + line_item.quantity
27
                quantity = line_item.quantity
29
            items[item_id] = quantity
28
            items[item_id] = quantity
30
 
29
 
31
    print items
30
    print items
32
    
31
    
33
    try:
32
    try:
34
        userServiceClient.getClient().resetCart(transaction.shopping_cart_id, items);
33
        userServiceClient.get_client().resetCart(transaction.shopping_cart_id, items);
35
    except ShoppingCartException:
34
    except ShoppingCartException:
36
        print "Error while resetting the cart in the cart database"
35
        print "Error while resetting the cart in the cart database"
37
        print sys.exc_info()
36
        print sys.exc_info()
38
    except TException:
37
    except TException:
39
        print "Error while updating information in payment database."
38
        print "Error while updating information in payment database."
Line 42... Line 41...
42
        print "Unexpected exception"
41
        print "Unexpected exception"
43
        print sys.exc_info()
42
        print sys.exc_info()
44
 
43
 
45
def track_coupon_usage(transaction, userServiceClient):
44
def track_coupon_usage(transaction, userServiceClient):
46
    try:
45
    try:
47
        cart = userServiceClient.getClient().getCart(transaction.shopping_cart_id)
46
        cart = userServiceClient.get_client().getCart(transaction.shopping_cart_id)
48
        coupon_code = cart.coupon_code
47
        coupon_code = cart.coupon_code
49
        
48
        
50
        if coupon_code is not None and coupon_code != '':
49
        if coupon_code is not None and coupon_code != '':
51
            PromotionClient().get_client().trackCouponUsage(coupon_code, transaction.id, transaction.customer_id);
50
            PromotionClient().get_client().trackCouponUsage(coupon_code, transaction.id, transaction.customer_id);
52
    except ShoppingCartException:
51
    except ShoppingCartException: