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


Python Order.cart方法代码示例

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


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

示例1: get

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import cart [as 别名]
	def get(self, request, *args, **kwargs):
		get_data = super(CheckoutView, self).get(request, *args, **kwargs)

		cart = self.get_object()
		user_checkout_id = request.session.get("user_checkout_id")
		if user_checkout_id != None:
			user_checkout = UserCheckout.objects.get(id=user_checkout_id)
			billing_address_id = request.session.get("billing_address_id")
			shipping_address_id = request.session.get("shipping_address_id")

			if billing_address_id == None or shipping_address_id == None:
				return redirect("order_address")
			else:
				billing_address = UserAddress.objects.get(id=billing_address_id)
				shipping_address = UserAddress.objects.get(id=shipping_address_id)
			
			

			new_order = Order()
			new_order.cart = cart
			new_order.user = user_checkout
			new_order.billing_address = billing_address
			new_order.shipping_address = shipping_address
			new_order.save()
		return get_data
开发者ID:chensheng123,项目名称:Django-Projects,代码行数:27,代码来源:views.py

示例2: checkout

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import cart [as 别名]
def checkout(request):

    ## using the session we created during carts to collect the cart_id.
    try:
        the_id = request.session['cart_id']
        cart= Cart.objects.get(id= the_id)
        print cart
    except :
        the_id= None
    ## Redirects to a url that we had initially configured in django urls page
        return HttpResponseRedirect(reverse("cart"))

# Creating a new instance if there is no order present. This instance will be saved as the
# new order.
    try:
        new_order = Order.objects.get(cart=cart)
    except Order.DoesNotExist:
        new_order = Order()
        new_order.cart = cart
        new_order.user = request.user
        new_order.order_id = id_generator()
        new_order.save()
   # it will return the user back to the cart
    except:
        return HttpResponseRedirect(reverse("cart"))




   # If the order is indicated as finished the cart will be deleted as well as
    # resetting the total number of items back to zero.
    if new_order.status== "Finished":
        del request.session['cart_id']
        del request.session['items_total']
        return HttpResponseRedirect(reverse("cart"))

    context={}
    return render(request, "products/home.html", context)
开发者ID:cmwaura,项目名称:Ecommerce-Application,代码行数:40,代码来源:views.py

示例3: checkout

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import cart [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

示例4: checkout_saved_cc

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import cart [as 别名]
def checkout_saved_cc(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)
        cc_id = request.POST['ccRadios']
        cc = CreditCard.objects.get(id=cc_id)
    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.POST:
        order = new_order
        amount = int(order.total * 100)  # convert to cents
        fee = int(order.total * 100 * settings.TRINITY_FEE * .01)  # % of inputed ($) amount, in cents
        customer = cc.stripe_id
        try:
            charge = stripe.Charge.create(
                amount=amount,  # amount in cents, again
                currency="usd",
                application_fee=fee,
                customer=customer,
                api_key=settings.TRINITY_API_KEY,
            )

            order.status = "Finished"
            order.payer_name = cc.payer_name
            order.payer_email = cc.payer_email
            order.last4 = cc.last4
            order.card_type = cc.card_type
            order.save()

            order_id = order.order_id
            # make records here:
            # get recipient, check for last record. is last record greater than sub. first issue?
            # first look for latest record for this recipient, if greater than subscription.first_issue

            print "HERE in checkout-cc, we are going to make recrods"

            print "order is %s" % order
            print "cart is %s" % cart
            print "cart items is %s" % cart_items
            print "subbies is %s" % subbies
            print "singlges is %s" % singles

            for sub in subbies:
                # two paths here- regular subbie and renewal
                print "wea are in subbie path"
                recipient = sub.recipient
                print recipient
                print "type is %s" % sub.subscription.type
                if sub.subscription.type == 2:  # renewal
                    print "chcekout cc, renewal"
                    last_record = Record.objects.filter(recipient=recipient).order_by('issue').last()
                    ish = last_record.issue + 1
                else:  # not renewal
                    print "checkout cc not renewal"
                    ish = sub.subscription.first_issue

                # try:
                #    all_record = Record.objects.get(recipient=sub.recipient, originating_order=order, issue=ish)

                for x in range(0, sub.subscription.term):
                    try:
                        record = Record.objects.get(recipient=sub.recipient, originating_order=order, issue=ish)
                        pass
                    except Record.DoesNotExist:
                        new_record = Record(recipient=sub.recipient, originating_order=order, issue=ish)
                        new_record.save()
                    ish += 1

            for single in singles:
                ish = int(single.single.slug)
                print "cehkout cc single"
                try:
                    bo = BackIssue.objects.get(
                        recipient=order.main_recipient, originating_order=order, issue=ish, quantity=single.quantity)
                    pass
                except BackIssue.DoesNotExist:
                    new_bo = BackIssue(
                        recipient=order.main_recipient, originating_order=order, issue=ish, quantity=single.quantity)
                    new_bo.save()

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


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