當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。