| 557 |
chandransh |
1 |
'''
|
|
|
2 |
Created on 10-May-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
|
|
6 |
from elixir import *
|
| 576 |
chandransh |
7 |
from shop2020.model.v1.user.impl.Dataservice import Cart, Line, Address, User
|
| 557 |
chandransh |
8 |
from shop2020.thriftpy.model.v1.user.ttypes import CartStatus, LineStatus, ShoppingCartException
|
|
|
9 |
import datetime
|
| 576 |
chandransh |
10 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
| 557 |
chandransh |
11 |
|
| 576 |
chandransh |
12 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as TTransaction,\
|
| 685 |
chandransh |
13 |
TransactionStatus as TTransactionStatus, Order as TOrder, LineItem as TLineItem, OrderStatus
|
| 557 |
chandransh |
14 |
|
| 576 |
chandransh |
15 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
|
| 844 |
chandransh |
16 |
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo as TLogisticsInfo,\
|
|
|
17 |
LogisticsServiceException
|
| 576 |
chandransh |
18 |
|
|
|
19 |
from shop2020.clients.TransactionClient import TransactionClient
|
|
|
20 |
from shop2020.clients.InventoryClient import InventoryClient
|
|
|
21 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
|
|
22 |
from shop2020.model.v1 import user
|
| 1976 |
varun.gupt |
23 |
from shop2020.clients.PromotionClient import PromotionClient
|
| 576 |
chandransh |
24 |
|
| 557 |
chandransh |
25 |
def get_cart(user_id):
|
|
|
26 |
query = Cart.query.filter_by(user_id=user_id)
|
|
|
27 |
query = query.filter_by(cart_status = CartStatus.ACTIVE)
|
|
|
28 |
try:
|
|
|
29 |
cart = query.one()
|
|
|
30 |
session.commit()
|
|
|
31 |
except:
|
|
|
32 |
return None
|
|
|
33 |
# raise ShoppingCartException(101, "Cart does not exist")
|
|
|
34 |
return cart
|
|
|
35 |
|
|
|
36 |
def get_cart_by_id(id):
|
|
|
37 |
cart = Cart.get_by(id=id)
|
|
|
38 |
return cart
|
|
|
39 |
|
|
|
40 |
def create_cart(user_id):
|
|
|
41 |
cart = get_cart(user_id)
|
|
|
42 |
if not cart:
|
|
|
43 |
cart = Cart()
|
|
|
44 |
cart.user_id = user_id
|
|
|
45 |
cart.created_on = datetime.datetime.now()
|
|
|
46 |
cart.updated_on = datetime.datetime.now()
|
|
|
47 |
cart.cart_status = CartStatus.ACTIVE
|
|
|
48 |
session.commit()
|
|
|
49 |
return cart
|
|
|
50 |
|
|
|
51 |
def get_cart_by_user_id_and_status(user_id, status):
|
|
|
52 |
query = Cart.query.filter_by(user_id=user_id)
|
|
|
53 |
if status:
|
|
|
54 |
query = query.filter_by(cart_status=status)
|
|
|
55 |
carts = query.all()
|
|
|
56 |
return carts
|
|
|
57 |
|
|
|
58 |
def get_carts_by_status(status):
|
|
|
59 |
return Cart.query.filter_by(cart_status=status).all()
|
|
|
60 |
|
|
|
61 |
def get_carts_between(start_time, end_time, status):
|
|
|
62 |
init_time = to_py_date(start_time)
|
|
|
63 |
finish_time = to_py_date(end_time)
|
|
|
64 |
|
|
|
65 |
query = Cart.query
|
|
|
66 |
if status:
|
|
|
67 |
query = query.filter(Cart.cart_status==status)
|
|
|
68 |
if init_time:
|
|
|
69 |
query = query.filter(Cart.created_on >= init_time)
|
|
|
70 |
if finish_time:
|
|
|
71 |
query = query.filter(Cart.created_on <= finish_time)
|
|
|
72 |
|
|
|
73 |
carts = query.all()
|
|
|
74 |
return carts
|
|
|
75 |
|
| 643 |
chandransh |
76 |
def get_line(item_id, cart_id, status, single):
|
| 557 |
chandransh |
77 |
#get cart first
|
|
|
78 |
try:
|
|
|
79 |
found_cart = Cart.get_by(id=cart_id)
|
|
|
80 |
except:
|
|
|
81 |
raise ShoppingCartException(101, "cart not found ")
|
| 643 |
chandransh |
82 |
query = Line.query.filter_by(cart = found_cart, item_id = item_id)
|
| 557 |
chandransh |
83 |
|
|
|
84 |
if status:
|
|
|
85 |
query = query.filter_by(line_status = status)
|
|
|
86 |
else:
|
|
|
87 |
query = query.filter_by(line_status = LineStatus.LINE_ACTIVE)
|
|
|
88 |
try:
|
|
|
89 |
if single:
|
|
|
90 |
return query.one()
|
|
|
91 |
else:
|
|
|
92 |
return query.all()
|
|
|
93 |
except:
|
|
|
94 |
return None
|
|
|
95 |
|
|
|
96 |
def change_cart_status(cart_id, status):
|
|
|
97 |
cart = get_cart_by_id(id)
|
|
|
98 |
if not cart:
|
|
|
99 |
raise ShoppingCartException(101, "no cart attached to this id")
|
|
|
100 |
if not status:
|
|
|
101 |
raise ShoppingCartException(101, "invalid status")
|
| 690 |
chandransh |
102 |
cart.cart_status = status
|
| 557 |
chandransh |
103 |
session.commit()
|
|
|
104 |
|
|
|
105 |
def add_item_to_cart(cart_id, item_id, quantity):
|
|
|
106 |
if not item_id:
|
|
|
107 |
raise ShoppingCartException(101, "item_id cannot be null")
|
|
|
108 |
|
|
|
109 |
if not quantity:
|
|
|
110 |
raise ShoppingCartException(101, "quantity cannot be null")
|
| 643 |
chandransh |
111 |
|
|
|
112 |
cart = Cart.get_by(id = cart_id)
|
| 557 |
chandransh |
113 |
if not cart:
|
|
|
114 |
raise ShoppingCartException(101, "no cart attached to this id")
|
|
|
115 |
|
| 643 |
chandransh |
116 |
current_time = datetime.datetime.now()
|
|
|
117 |
cart.updated_on = current_time
|
|
|
118 |
line = get_line(item_id, cart_id, None,True)
|
|
|
119 |
if line:
|
|
|
120 |
#change the quantity only
|
|
|
121 |
line.quantity = quantity
|
| 685 |
chandransh |
122 |
line.updated_on = current_time
|
| 643 |
chandransh |
123 |
else:
|
|
|
124 |
line = Line()
|
|
|
125 |
line.cart = cart
|
|
|
126 |
line.item_id = item_id
|
|
|
127 |
line.quantity = quantity
|
|
|
128 |
line.created_on = current_time
|
|
|
129 |
line.updated_on = current_time
|
|
|
130 |
line.line_status = LineStatus.LINE_ACTIVE
|
| 557 |
chandransh |
131 |
session.commit()
|
| 1621 |
rajveer |
132 |
#validate_cart(cart_id)
|
| 557 |
chandransh |
133 |
|
|
|
134 |
def delete_item_from_cart(cart_id, item_id):
|
|
|
135 |
if not item_id:
|
|
|
136 |
raise ShoppingCartException(101, "item_id cannot be null")
|
| 685 |
chandransh |
137 |
cart = Cart.get_by(id = cart_id)
|
|
|
138 |
if not cart:
|
|
|
139 |
raise ShoppingCartException(101, "no cart attached to this id")
|
| 643 |
chandransh |
140 |
item = get_line(item_id, cart_id, None, True)
|
| 557 |
chandransh |
141 |
item.delete()
|
| 685 |
chandransh |
142 |
current_time = datetime.datetime.now()
|
|
|
143 |
cart.updated_on = current_time
|
| 557 |
chandransh |
144 |
session.commit()
|
|
|
145 |
|
|
|
146 |
def change_item_status(cart_id, item_id, status):
|
|
|
147 |
if not status:
|
|
|
148 |
raise ShoppingCartException(101, "Status cannot be made null")
|
| 685 |
chandransh |
149 |
line = get_line(item_id, cart_id, None, True)
|
|
|
150 |
if line:
|
|
|
151 |
line.line_status = status
|
|
|
152 |
current_time = datetime.datetime.now()
|
|
|
153 |
line.updated_on = current_time
|
|
|
154 |
line.cart.updated_on = current_time
|
| 557 |
chandransh |
155 |
session.commit()
|
|
|
156 |
else:
|
| 685 |
chandransh |
157 |
raise ShoppingCartException(101, "Unable to probe the line you desired")
|
| 557 |
chandransh |
158 |
|
|
|
159 |
def add_address_to_cart(cart_id, address_id):
|
|
|
160 |
if not cart_id:
|
|
|
161 |
raise ShoppingCartException(101, "cart id cannot be made null")
|
|
|
162 |
|
|
|
163 |
if not address_id:
|
|
|
164 |
raise ShoppingCartException(101, "address id cannot be made null")
|
|
|
165 |
|
|
|
166 |
cart = get_cart_by_id(cart_id)
|
|
|
167 |
if not cart:
|
|
|
168 |
raise ShoppingCartException(101, "no cart for this id")
|
| 576 |
chandransh |
169 |
|
|
|
170 |
address = Address.get_by(id=address_id)
|
|
|
171 |
if not address:
|
|
|
172 |
raise ShoppingCartException(101, "No address for this id")
|
|
|
173 |
|
| 557 |
chandransh |
174 |
cart.address_id = address_id
|
| 685 |
chandransh |
175 |
current_time = datetime.datetime.now()
|
| 716 |
rajveer |
176 |
#cart.updated_on = current_time
|
| 557 |
chandransh |
177 |
session.commit()
|
|
|
178 |
|
| 1976 |
varun.gupt |
179 |
def apply_coupon_to_cart(cart_id, coupon_code, total_price, discounted_price):
|
|
|
180 |
cart = get_cart_by_id(cart_id)
|
|
|
181 |
if not cart:
|
|
|
182 |
raise ShoppingCartException(101, "no cart attached to this id")
|
|
|
183 |
cart.total_price = total_price
|
|
|
184 |
cart.discounted_price = discounted_price
|
|
|
185 |
cart.coupon_code = coupon_code
|
|
|
186 |
session.commit()
|
|
|
187 |
|
|
|
188 |
def remove_coupon(cart_id):
|
|
|
189 |
cart = get_cart_by_id(cart_id)
|
|
|
190 |
if not cart:
|
|
|
191 |
raise ShoppingCartException(101, "no cart attached to this id")
|
|
|
192 |
cart.discounted_price = None
|
|
|
193 |
cart.coupon_code = None
|
|
|
194 |
session.commit()
|
|
|
195 |
|
| 576 |
chandransh |
196 |
def commit_cart(cart_id):
|
| 690 |
chandransh |
197 |
cart = get_cart_by_id(cart_id)
|
| 557 |
chandransh |
198 |
#now we have a cart. Need to create a transaction with it
|
| 576 |
chandransh |
199 |
txn = TTransaction()
|
|
|
200 |
txn.shoppingCartid = cart_id
|
|
|
201 |
txn.customer_id = cart.user_id
|
|
|
202 |
txn.createdOn = to_java_date(datetime.datetime.now())
|
|
|
203 |
txn.transactionStatus = TTransactionStatus.INIT
|
|
|
204 |
txn.statusDescription = "New Order"
|
| 557 |
chandransh |
205 |
|
| 576 |
chandransh |
206 |
txn.orders = create_orders(cart)
|
|
|
207 |
|
|
|
208 |
transaction_client = TransactionClient().get_client()
|
|
|
209 |
txn_id = transaction_client.createTransaction(txn)
|
|
|
210 |
session.commit()
|
|
|
211 |
|
| 685 |
chandransh |
212 |
#new_cart = create_cart(cart.user_id)
|
|
|
213 |
#user = User.get_by(id=cart.user_id)
|
|
|
214 |
#user.active_cart_id = new_cart.id
|
|
|
215 |
#session.commit()
|
| 576 |
chandransh |
216 |
return txn_id
|
|
|
217 |
|
|
|
218 |
def create_orders(cart):
|
| 557 |
chandransh |
219 |
cart_lines = cart.lines
|
| 576 |
chandransh |
220 |
orders = []
|
|
|
221 |
|
| 557 |
chandransh |
222 |
for line in cart_lines:
|
| 576 |
chandransh |
223 |
if line.line_status == LineStatus.LINE_ACTIVE:
|
|
|
224 |
i = 0
|
|
|
225 |
while i< line.quantity:
|
| 1976 |
varun.gupt |
226 |
t_line_item = create_line_item(line.item_id, line.discounted_price)
|
| 576 |
chandransh |
227 |
t_order = create_order(cart.user_id, cart.address_id, t_line_item)
|
|
|
228 |
orders.append(t_order)
|
|
|
229 |
i += 1
|
|
|
230 |
return orders
|
|
|
231 |
|
|
|
232 |
def create_order(user_id, address_id, t_line_item):
|
|
|
233 |
user = User.get_by(id=user_id)
|
|
|
234 |
address = Address.get_by(id=address_id)
|
|
|
235 |
t_order = TOrder()
|
| 557 |
chandransh |
236 |
|
| 576 |
chandransh |
237 |
t_order.customer_id = user.id
|
|
|
238 |
t_order.customer_email = user.email
|
|
|
239 |
|
| 910 |
rajveer |
240 |
t_order.customer_name = address.name
|
| 576 |
chandransh |
241 |
t_order.customer_pincode = address.pin
|
| 738 |
chandransh |
242 |
t_order.customer_address1 = address.line_1
|
|
|
243 |
t_order.customer_address2 = address.line_2
|
| 669 |
chandransh |
244 |
t_order.customer_city = address.city
|
|
|
245 |
t_order.customer_state = address.state
|
| 576 |
chandransh |
246 |
t_order.customer_mobilenumber = address.phone
|
|
|
247 |
|
|
|
248 |
t_order.total_amount = t_line_item.total_price
|
| 1976 |
varun.gupt |
249 |
|
| 576 |
chandransh |
250 |
t_order.total_weight = t_line_item.total_weight
|
|
|
251 |
t_order.lineitems = [t_line_item]
|
|
|
252 |
|
| 690 |
chandransh |
253 |
t_order.status = OrderStatus.PAYMENT_PENDING
|
| 970 |
chandransh |
254 |
t_order.statusDescription = "Payment Pending"
|
| 576 |
chandransh |
255 |
t_order.created_timestamp = to_java_date(datetime.datetime.now())
|
|
|
256 |
|
| 743 |
rajveer |
257 |
# this code is moved somewhere else, as now order will be created but we dont want to add awb number etc
|
|
|
258 |
'''
|
| 576 |
chandransh |
259 |
logistics_client = LogisticsClient().get_client()
|
| 716 |
rajveer |
260 |
logistics_info = logistics_client.getLogisticsInfo(t_order.customer_pincode, t_line_item.item_id)
|
| 576 |
chandransh |
261 |
|
| 716 |
rajveer |
262 |
t_order.logistics_provider_id = logistics_info.providerId
|
| 576 |
chandransh |
263 |
t_order.airwaybill_no = logistics_info.airway_billno
|
|
|
264 |
t_order.tracking_id = t_order.airwaybill_no
|
| 716 |
rajveer |
265 |
t_order.expected_delivery_time = to_java_date(datetime.datetime.now()) + 60*60*1000*logistics_info.deliveryTime
|
|
|
266 |
t_order.warehouse_id = logistics_info.warehouseId
|
| 743 |
rajveer |
267 |
'''
|
|
|
268 |
|
| 576 |
chandransh |
269 |
return t_order
|
|
|
270 |
|
| 1976 |
varun.gupt |
271 |
def create_line_item(item_id, discounted_price):
|
| 576 |
chandransh |
272 |
inventory_client = InventoryClient().get_client()
|
| 636 |
rajveer |
273 |
item = inventory_client.getItem(item_id)
|
| 576 |
chandransh |
274 |
t_line_item = TLineItem()
|
| 963 |
chandransh |
275 |
t_line_item.productGroup = item.productGroup
|
|
|
276 |
t_line_item.brand = item.brand
|
| 636 |
rajveer |
277 |
t_line_item.model_number = item.modelNumber
|
| 669 |
chandransh |
278 |
if item.color is None or item.color == "NA":
|
|
|
279 |
t_line_item.color = ""
|
|
|
280 |
else:
|
| 917 |
chandransh |
281 |
t_line_item.color = item.color
|
| 963 |
chandransh |
282 |
t_line_item.model_name = item.modelName
|
| 636 |
rajveer |
283 |
t_line_item.extra_info = item.featureDescription
|
| 702 |
chandransh |
284 |
t_line_item.item_id = item.id
|
| 576 |
chandransh |
285 |
t_line_item.quantity = 1
|
| 1983 |
varun.gupt |
286 |
|
|
|
287 |
if discounted_price is None or discounted_price == 0:
|
|
|
288 |
t_line_item.unit_price = item.sellingPrice
|
|
|
289 |
t_line_item.total_price = item.sellingPrice
|
|
|
290 |
else:
|
|
|
291 |
t_line_item.unit_price = discounted_price
|
|
|
292 |
t_line_item.total_price = discounted_price
|
|
|
293 |
|
| 636 |
rajveer |
294 |
t_line_item.unit_weight = item.weight
|
|
|
295 |
t_line_item.total_weight = item.weight
|
| 576 |
chandransh |
296 |
return t_line_item
|
|
|
297 |
|
|
|
298 |
def validate_cart(cartId):
|
|
|
299 |
inventory_client = InventoryClient().get_client()
|
|
|
300 |
logistics_client = LogisticsClient().get_client()
|
| 1976 |
varun.gupt |
301 |
promotion_client = PromotionClient().get_client()
|
| 1466 |
ankur.sing |
302 |
retval = ""
|
| 557 |
chandransh |
303 |
# No need to validate duplicate items since there are only two ways
|
|
|
304 |
# to add items to a cart and both of them check whether the item being
|
|
|
305 |
# added is a duplicate of an already existing item.
|
| 563 |
chandransh |
306 |
cart = Cart.get_by(id=cartId)
|
|
|
307 |
cart_lines = cart.lines
|
| 776 |
rajveer |
308 |
customer_pincode = None
|
| 690 |
chandransh |
309 |
current_time = datetime.datetime.now()
|
| 576 |
chandransh |
310 |
if cart.address_id:
|
|
|
311 |
address = Address.get_by(id=cart.address_id)
|
|
|
312 |
customer_pincode = address.pin
|
| 776 |
rajveer |
313 |
if not customer_pincode:
|
| 785 |
rajveer |
314 |
user = User.get_by(active_cart_id = cartId)
|
|
|
315 |
default_address_id = user.default_address_id
|
| 776 |
rajveer |
316 |
if default_address_id:
|
|
|
317 |
address = Address.get_by(id = default_address_id)
|
|
|
318 |
customer_pincode = address.pin
|
|
|
319 |
if not customer_pincode:
|
|
|
320 |
#FIXME should not be hard coded. May be we can pick from config server.
|
|
|
321 |
customer_pincode = "110001"
|
| 1976 |
varun.gupt |
322 |
cart.total_price = 0
|
| 563 |
chandransh |
323 |
for line in cart_lines:
|
| 612 |
chandransh |
324 |
old_estimate = line.estimate
|
| 636 |
rajveer |
325 |
item_id = line.item_id
|
| 1976 |
varun.gupt |
326 |
item = inventory_client.getItem(item_id)
|
| 636 |
rajveer |
327 |
if inventory_client.isActive(item_id):
|
| 1976 |
varun.gupt |
328 |
line.actual_price = item.sellingPrice
|
|
|
329 |
cart.total_price = cart.total_price + line.actual_price
|
| 776 |
rajveer |
330 |
try:
|
|
|
331 |
item_delivery_estimate = logistics_client.getLogisticsEstimation(item_id, customer_pincode).deliveryTime
|
| 844 |
chandransh |
332 |
except LogisticsServiceException:
|
|
|
333 |
item_delivery_estimate = -1
|
|
|
334 |
#TODO Use the exception clause to set the retval appropriately
|
|
|
335 |
except :
|
|
|
336 |
item_delivery_estimate = -1
|
| 776 |
rajveer |
337 |
if old_estimate != item_delivery_estimate:
|
|
|
338 |
line.estimate = item_delivery_estimate
|
|
|
339 |
cart.updated_on = current_time
|
| 1466 |
ankur.sing |
340 |
if old_estimate != None:
|
|
|
341 |
retval = "Delivery Estimates updated."
|
| 576 |
chandransh |
342 |
else:
|
| 563 |
chandransh |
343 |
line.delete()
|
| 1466 |
ankur.sing |
344 |
retval = "Some items have been removed from the cart."
|
| 716 |
rajveer |
345 |
if cart.checked_out_on is not None:
|
|
|
346 |
if cart.updated_on > cart.checked_out_on:
|
| 844 |
chandransh |
347 |
cart.checked_out_on = None
|
| 1466 |
ankur.sing |
348 |
if retval == "":
|
|
|
349 |
retval = "Your cart has been updated after the last checkout."
|
| 612 |
chandransh |
350 |
session.commit()
|
| 1976 |
varun.gupt |
351 |
|
|
|
352 |
if cart.coupon_code is not None:
|
|
|
353 |
updated_cart = promotion_client.applyCoupon(cart.coupon_code, cart.id)
|
|
|
354 |
for t_line in updated_cart.lines:
|
|
|
355 |
#Find the line in the database which corresponds to this line
|
|
|
356 |
line = Line.query.filter_by(cart = cart).filter_by(item_id = t_line.itemId).one()
|
|
|
357 |
#Update its discounted price.
|
|
|
358 |
line.discounted_price = t_line.discountedPrice
|
|
|
359 |
cart.discounted_price = updated_cart.discountedPrice
|
|
|
360 |
session.commit()
|
| 563 |
chandransh |
361 |
return retval
|
| 576 |
chandransh |
362 |
|
| 557 |
chandransh |
363 |
def merge_cart(fromCartId, toCartId):
|
|
|
364 |
fromCart = Cart.get_by(id=fromCartId)
|
|
|
365 |
toCart = Cart.get_by(id=toCartId)
|
|
|
366 |
|
|
|
367 |
old_lines = fromCart.lines
|
|
|
368 |
new_lines = toCart.lines
|
|
|
369 |
|
|
|
370 |
for line in old_lines:
|
|
|
371 |
flag = True
|
|
|
372 |
for new_line in new_lines:
|
|
|
373 |
if line.item_id == new_line.item_id:
|
|
|
374 |
flag = False
|
| 576 |
chandransh |
375 |
if flag:
|
| 557 |
chandransh |
376 |
toCart.lines.append(line)
|
|
|
377 |
|
|
|
378 |
toCart.updatedOn = datetime.datetime.now()
|
|
|
379 |
|
|
|
380 |
fromCart.expired_on = datetime.datetime.now()
|
|
|
381 |
fromCart.cart_status = CartStatus.INACTIVE
|
| 643 |
chandransh |
382 |
session.commit()
|
| 691 |
chandransh |
383 |
|
|
|
384 |
def check_out(cartId):
|
|
|
385 |
if cartId is None:
|
|
|
386 |
raise ShoppingCartException(101, "Cart id not specified")
|
| 716 |
rajveer |
387 |
cart = Cart.get_by(id = cartId)
|
| 691 |
chandransh |
388 |
if cart is None:
|
|
|
389 |
raise ShoppingCartException(102, "The specified cart couldn't be found")
|
|
|
390 |
cart.checked_out_on = datetime.datetime.now()
|
|
|
391 |
session.commit()
|
|
|
392 |
return True
|
|
|
393 |
|
|
|
394 |
def reset_cart(cartId, items):
|
|
|
395 |
if cartId is None:
|
|
|
396 |
raise ShoppingCartException(101, "Cart id not specified")
|
|
|
397 |
for item_id, quantity in items.iteritems():
|
|
|
398 |
line = Line.query.filter_by(cart_id=cartId, item_id=item_id).one()
|
|
|
399 |
if line is not None:
|
|
|
400 |
line.quantity = line.quantity - quantity
|
|
|
401 |
if line.quantity == 0:
|
|
|
402 |
line.delete()
|
| 717 |
rajveer |
403 |
cart = Cart.get_by(id=cartId)
|
| 691 |
chandransh |
404 |
cart.updated_on = datetime.datetime.now()
|
| 1894 |
vikas |
405 |
cart.checked_out_on = None
|
| 1976 |
varun.gupt |
406 |
|
|
|
407 |
# Removing Coupon
|
|
|
408 |
cart.total_price = None
|
|
|
409 |
cart.discounted_price = None
|
|
|
410 |
cart.coupon_code = None
|
|
|
411 |
|
| 691 |
chandransh |
412 |
session.commit()
|
| 766 |
rajveer |
413 |
return True
|
|
|
414 |
|
|
|
415 |
def close_session():
|
|
|
416 |
if session.is_active:
|
|
|
417 |
print "session is active. closing it."
|
| 1621 |
rajveer |
418 |
session.close()
|