コード例 #1
0
ファイル: views-back.py プロジェクト: mws2j/Textile
def checkout(request):

    context = RequestContext(request)
    cart = request.session['cartList']
    myOrder = Order()  # we have an order object now
    myOrder.orderDate = timezone.now()  # date for the order is now
    # these will need to come after probably - I just want to save it
    myOrder.shippingCost = 1
    myOrder.totalCost = 2
    myOrder.save()

    for itemlist in cart:  # remember that cart is an array of arrays that have name, quantity, price
        storeItem = StoreItem.objects.get(itemName=itemlist[0])
        orderItem = OrderItemCorrect(order=myOrder,
                                     itemID=storeItem,
                                     itemCost=storeItem.price,
                                     itemQuantity=int(itemlist[1]))
        orderItem.save(force_insert=True)

    itemsInOrder = myOrder.orderitemcorrect_set.all()
    # subtotal = 0
    #for orderItem in order.item: # loop through a foreign key?
    #    subtotal += orderItem.itemCost
    # print "Subtotal for order: ", subtotal
    # order.shippingCost = 0 # insert shipping calc here... maybe?
    # order.totalCost = order.shippingCost + subtotal
    # order.save()
    # associate order with user
    return render_to_response('store/checkout.html', {
        'order': myOrder,
        'items': itemsInOrder,
        'success': True
    }, context)
コード例 #2
0
ファイル: views-back.py プロジェクト: devgr/Tektiles
def checkout(request):

	context = RequestContext(request)
	cart = request.session['cartList']
	myOrder = Order() # we have an order object now
	myOrder.orderDate = timezone.now() # date for the order is now
	# these will need to come after probably - I just want to save it
	myOrder.shippingCost = 1
	myOrder.totalCost = 2
	myOrder.save()


	for itemlist in cart: # remember that cart is an array of arrays that have name, quantity, price
		storeItem = StoreItem.objects.get(itemName=itemlist[0])
		orderItem = OrderItemCorrect(
			order = myOrder,
			itemID = storeItem,
			itemCost = storeItem.price,
			itemQuantity = int(itemlist[1])
		)
		orderItem.save(force_insert=True)
	
	itemsInOrder = myOrder.orderitemcorrect_set.all()
	# subtotal = 0
	#for orderItem in order.item: # loop through a foreign key?
	#    subtotal += orderItem.itemCost
	# print "Subtotal for order: ", subtotal
	# order.shippingCost = 0 # insert shipping calc here... maybe?
	# order.totalCost = order.shippingCost + subtotal
	# order.save()
	# associate order with user
	return render_to_response('store/checkout.html',{'order':myOrder, 'items':itemsInOrder, 'success': True},context)
コード例 #3
0
ファイル: views.py プロジェクト: AustinBRFerrell/Textile
def checkout(request):

	context = RequestContext(request)
	cart = request.session['cartList']
	myOrder = Order() # we have an order object now
	myOrder.orderDate = timezone.now() # date for the order is now
	# these will need to come after probably - I just want to save it
	myOrder.shippingCost = 0
	myOrder.totalCost = 2
	myOrder.save()


	for itemlist in cart: # remember that cart is an array of arrays that have name, quantity, price
		#orderItem = OrderItemCorrect()
		#print "cleaning the order item model"
		# orderItem.full_clean()
		storeItem = StoreItem.objects.get(itemNameid=itemlist[0])
		orderItem = OrderItemCorrect(
			order = myOrder,
			itemID = storeItem,
			itemCost = storeItem.price,
			itemQuantity = int(itemlist[1])
		)
		orderItem.save(force_insert=True)
	
	itemsInOrder = myOrder.orderitemcorrect_set.all()
	
	subtotal = 0
	for items in itemsInOrder:
		subtotal += items.itemCost * items.itemQuantity
	boxDimensions = boxFit(itemsInOrder)
	needToEmail = False
	weight = 0
	if boxDimensions == (0, 0, 0): # determined that it needs to be a manual order
		needToEmail = True 
	else:
		weight = getWeight(itemsInOrder) # calculate weight if it can be shipped
	myOrder.totalCost = subtotal + myOrder.shippingCost # shipping cost is figured out at a later point
	myOrder.save()
	# need to cast as int for stripe to accept it
	cents = int(myOrder.totalCost * 100)
	print cents

	return render_to_response('store/checkout.html',{'weight':weight,'boxW':boxDimensions[0],'boxH':boxDimensions[1],'boxD':boxDimensions[2],'needToEmail':needToEmail,'cents':cents,'order':myOrder, 'items':itemsInOrder, 'success': True},context)
コード例 #4
0
def checkout(request):

	context = RequestContext(request)
	cart = request.session['cartList']
	myOrder = Order() # we have an order object now
	myOrder.orderDate = timezone.now() # date for the order is now
	# these will need to come after probably - I just want to save it
	myOrder.shippingCost = 0
	myOrder.totalCost = 2
	myOrder.save()


	for itemlist in cart: # remember that cart is an array of arrays that have name, quantity, price
		#orderItem = OrderItemCorrect()
		#print "cleaning the order item model"
		# orderItem.full_clean()
		storeItem = StoreItem.objects.get(itemNameid=itemlist[0])
		orderItem = OrderItemCorrect(
			order = myOrder,
			itemID = storeItem,
			itemCost = storeItem.price,
			itemQuantity = int(itemlist[1])
		)
		orderItem.save(force_insert=True)
	
	itemsInOrder = myOrder.orderitemcorrect_set.all()
	
	subtotal = 0
	for items in itemsInOrder:
		subtotal += items.itemCost * items.itemQuantity
	boxDimensions = boxFit(itemsInOrder)
	needToEmail = False
	weight = 0
	if boxDimensions == (0, 0, 0): # determined that it needs to be a manual order
		needToEmail = True 
	else:
		weight = getWeight(itemsInOrder) # calculate weight if it can be shipped
	myOrder.totalCost = subtotal + myOrder.shippingCost # shipping cost is figured out at a later point
	myOrder.save()
	cents = myOrder.totalCost * 100


	return render_to_response('store/checkout.html',{'weight':weight,'boxW':boxDimensions[0],'boxH':boxDimensions[1],'boxD':boxDimensions[2],'needToEmail':needToEmail,'cents':cents,'order':myOrder, 'items':itemsInOrder, 'success': True},context)