Ejemplo n.º 1
0
def checkout(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)
    saved_address = saved_address[0]
    print(saved_address)
    form = BillingForm(instance=saved_address)
    if request.method == "POST":
        form = BillingForm(request.POST, instance=saved_address)
        if form.is_valid():
            form.save()
            form = BillingForm(instance=saved_address)
            messages.success(request, f"Shipping Address Saved!")
    order_qs = Order.objects.filter(user=request.user, ordered=False)
    # print(order_qs)
    order_items = order_qs[0].orderitems.all()
    # print(order_items)
    order_total = order_qs[0].get_totals()
    return render(request,
                  'App_Payment/checkout.html',
                  context={
                      "form": form,
                      "order": order_qs[0],
                      "order_items": order_items,
                      "order_total": order_total,
                      "saved_address": saved_address
                  })
Ejemplo n.º 2
0
def checkout(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)[0]
    form = BillingForm(instance=saved_address)
    if request.method == "POST":
        form = BillingForm(request.POST, instance=saved_address)
        if form.is_valid():
            form.save()
            form = BillingForm(instance=saved_address)
            messages.success(request, f'Shipping Address Saved!')
    order_qs = Order.objects.filter(user=request.user, ordered=False)[0]
    order_items = order_qs.orderitems.all()
    order_total = order_qs.get_totals()
    order = Order.objects.get(user=request.user, ordered=False)
    coupon = Coupons.objects.all().values_list('code', 'code')
    promo = order.coupon

    return render(request,
                  'App_Payment/checkout.html',
                  context={
                      'form': form,
                      'promo': promo,
                      'order_items': order_items,
                      'order_total': order_total,
                      'saved_address': saved_address
                  })
Ejemplo n.º 3
0
def checkout(request):
	saved_address=BillingAddress.objects.get_or_create(user=request.user)
	save_address=saved_address[0]
	form=BillingForm(instance=save_address)
	if request.method =="POST":
		form=BillingForm(request.POST,instance=save_address)
		if form.is_valid():
			form.save()
			form=BillingForm(instance=save_address)
			messages.info(request,"Your address has been saved")
	order_qs = Order.objects.filter(user=request.user, ordered=False)
	order_items = order_qs[0].orderitems.all()
	order_total=order_qs[0].get_totals()
	return render(request,'App_Payment/checkout.html',context={'form':form,'order_items':order_items,'order_total':order_total,'save_address':save_address})
Ejemplo n.º 4
0
def checkout(request):
    saved_address = BillingAddress.objects.get_or_create(user = request.user )[0]
    form = BillingForm(instance=saved_address)

    if request.method == "POST" or request.method == "post":
        form = BillingForm(request.POST, instance=saved_address)

        if form.is_valid():
            form.save()
            # form = BillingForm(instance=saved_address)
            messages.success(request,f"Shipping Address saved successfully!")
    
    order_qs = Order.objects.filter(user = request.user , ordered=False)
    print(order_qs) 
    order_items = order_qs[0].orderitems.all()
    print(order_items)
    order_total = order_qs[0].get_total()
    print(order_total)

    return render(request,'App_Payment/checkout.html',context={'form':form,'order_items':order_items,'order_total':order_total,'saved_address':saved_address})