本文整理汇总了Python中cart.cart.Cart.get_book_price方法的典型用法代码示例。如果您正苦于以下问题:Python Cart.get_book_price方法的具体用法?Python Cart.get_book_price怎么用?Python Cart.get_book_price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cart.cart.Cart
的用法示例。
在下文中一共展示了Cart.get_book_price方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: order_create
# 需要导入模块: from cart.cart import Cart [as 别名]
# 或者: from cart.cart.Cart import get_book_price [as 别名]
def order_create(request):
cart = Cart(request)
if request.method == 'POST':
form = OrderCreateForm(request.POST)
if form.is_valid():
order = form.save(commit=False)
order.account_id = request.user
order.first_name = request.user.first_name
order.last_name = request.user.last_name
order.address = request.user.profile.address
order.phone = request.user.profile.cellphone
order.shipment_cost = cart.get_shipment_cost()
order.books_cost = cart.get_book_price()
order.save()
for item in cart:
OrderList.objects.create(order_id=order,
book_id=item['book'],
book_quantity=item['quantity'],
price=item['price'],
discount=item['discount'])
cart.clear()
order_created(request, order.id)
request.session['order_id'] = order.id
messages.success(request,
'Your order was successfully placed!Please Check your email!')
return redirect('IB:book_list')
else:
messages.error(request, 'Your order got somthing wrong!')
else:
form = OrderCreateForm()
return render(request,
'createOrder.html',
{'cart': cart,
'form': form})