当前位置: 首页>>代码示例>>Python>>正文


Python Order.transaction_id方法代码示例

本文整理汇总了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
开发者ID:dragonII,项目名称:ecomstore,代码行数:31,代码来源:checkout.py

示例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
    
开发者ID:BFrost,项目名称:django,代码行数:28,代码来源:checkout.py


注:本文中的models.Order.transaction_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。