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


Python Order.shipping方法代码示例

本文整理汇总了Python中orders.models.Order.shipping方法的典型用法代码示例。如果您正苦于以下问题:Python Order.shipping方法的具体用法?Python Order.shipping怎么用?Python Order.shipping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在orders.models.Order的用法示例。


在下文中一共展示了Order.shipping方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checkout

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import shipping [as 别名]
def checkout(request):
    try:
        the_cart_id = request.session['cart_id']
        cart = Cart.objects.get(id=the_cart_id)
        subbies = CartItem.subbie_type.filter(cart=cart)
        singles = CartItem.single_type.filter(cart=cart)
        cart_items = CartItem.objects.filter(cart=cart)

    except:
        the_cart_id = None
        return HttpResponseRedirect(reverse("view_cart"))

    try:
        user = request.user
    except:
        user = None

    try:

        new_order = Order.objects.get(cart=cart)
    except Order.DoesNotExist:
        new_order = Order()
        new_order.cart = cart
        new_order.order_id = id_generator()
        new_order.save()
    except:
        new_order = None
        return HttpResponseRedirect(reverse("view_cart"))

    if request.user.is_authenticated():
        new_order.user = request.user
        print new_order.user
        print "we gota  new order user"

    new_order.total = cart.total
    new_order.shipping = cart.shipping_total
    if new_order.coupon:
        coupon = new_order.coupon
        percent_discount = coupon.percent_discount
        new_total = new_order.total - new_order.total * (float(percent_discount) / 100)
        print new_total
        new_order.total = new_total
    new_order.save()
    pay_form = PayForm()
    order = new_order

    subgo = False
    singo = False
    paygo = False
    usergo = False

    if subbies and singles:
        for sub in subbies:
            if sub.recipient:
                subgo = True
            else:
                subgo = False
        if order.main_recipient:
            singo = True
        else:
            singo = False

        if subgo == True and singo == True:
            paygo = True
        else:
            paygo = False

    elif not subbies and singles:
        if order.main_recipient:
            singo = True
        else:
            singo = False

        if subgo == False and singo == True:
            paygo = True
        else:
            paygo = False

    elif subbies and not singles:
        for sub in subbies:
            if sub.recipient:
                subgo = True
            else:
                subgo = False

        if subgo == True and singo == False:
            paygo = True
        else:
            paygo = False

    # check user status
    user = request.user
    if user.is_authenticated():
        usergo = True
    elif singles and not subbies:
        usergo = True
    else:
        usergo = False

    if request.POST:
#.........这里部分代码省略.........
开发者ID:davogler,项目名称:POSTv3,代码行数:103,代码来源:views.py


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