本文整理汇总了Python中models.Order.transaction_id方法的典型用法代码示例。如果您正苦于以下问题:Python Order.transaction_id方法的具体用法?Python Order.transaction_id怎么用?Python Order.transaction_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.transaction_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import transaction_id [as 别名]
def create_order(request, transaction_id):
order = Order()
checkout_form = CheckoutForm(request.POST, instance = order)
order = checkout_form.save(commit = False)
order.transaction_id = transaction_id
order.ip_address = request.META.get('REMOTE_ADDR')
if request.user.is_authenticated():
order.user = request.user
order.status = Order.SUBMITTED
order.save()
# if the order save succeeded
if order.pk:
cart_items = shoppingcart.get_cart_items(request)
for ci in cart_items:
# create order item for each cart item
oi = OrderItem()
oi.order = order
oi.quantity = ci.quantity
oi.price = ci.price
oi.product = ci.product
oi.save()
# all set, empty card
shoppingcart.empty_cart(request)
# save profile info for future orders
if request.user.is_authenticated():
from accounts import profile
profile.set(request)
# return the new order object
return order
示例2: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import transaction_id [as 别名]
def create_order(request,transaction_id):
order = Order()
checkout_form = CheckoutForm(request.POST, instance=order)
order = checkout_form.save(commit=False)
order.transaction_id = transaction_id
order.ip_address = request.META.get('REMOTE_ADDR')
order.user = None
if request.user.is_authenticated():
order.user = request.user
order.status = Order.SUBMITTED
order.save()
if order.pk:
cart_items = cart.get_cart_items(request)
for ci in cart_items:
oi = OrderItem()
oi.order = order
oi.quantity = ci.quantity
oi.price = ci.price
oi.product = ci.product
oi.save()
cart.empty_cart(request)
if request.user.is_authenticated():
from accounts import profile
profile.set(request)
return order