小計算

關於總total 計算

https://stackoverflow.com/questions/70045275/how-to-save-shipping-information-when-proceed-with-payment-in-django-razorpay-gadef place_order(request,total= 0,quantity = 0):
cart = Cart.objects.get(cart_id = _cart_id(request))
cart_items = CartItem.objects.filter(cart = cart, status = True)

# cart_items = CartItem.objects.filter(user= current_user)
cart_count = cart_items.count()

if cart_count <= 0:
return redirect('login')

tax= 0
grant_total = 0
for item in cart_items:
total += (item.product.sale_price * item.quantity)
quantity += item.quantity
tax = (3*total)/100
grant_total = total+tax

if request.method == "POST":
order_number = request.POST.get('order_number')
full_name = request.POST.get('full_name')
mobile = request.POST.get('mobile')
email = request.POST.get('email')
address_line1 = request.POST.get('address_line1')
address_line2 = request.POST.get('address_line2')
country = request.POST.get('country')
state = request.POST.get('state')
city = request.POST.get('city')
order_note = request.POST.get('order_note')
tax = request.POST.get('tax')
grant_total = int(request.POST.get('order_total'))*100
status = request.POST.get('status')
amount = int(request.POST.get('amount')) * 100

# Create Rezorpay Client
client = razorpay.Client(auth=('rzp_test_ertermiaBf1212','ertgghg56Qp27UYlPEsghtedfes'))

# Create Order
callback_url = 'http://'+ str(get_current_site(request))+"/payment/handlerequest/"
response_payment = client.order.create(dict(amount=amount,
currency="INR")
)
order_id = response_payment['id']
order_status = response_payment['status']

if order_status == 'created':
order = Order(
order_number = order_number,
full_name = full_name,
mobile = mobile,
email = email,
address_line1 = address_line1,
address_line2 = address_line2,
country = country,
state = state,
city = city,
order_total = grant_total,
order_note = order_note,
amount =amount,
status = status,
tax =tax,
order_id = order_id,
)
order.save()
form = Order(request.POST or None)
return render(request, 'frontend/store/payment.html', {'form':form, 'pay':response_payment,'callback_url':callback_url})
form = OrderForm()
return render(request, 'frontend/store/payment.html', {'form':form})

Table Search in Django

def listOrder(request):
if request.method == "POST":
order_number = request.POST.get('order_number')
product_name = request.POST.get('product_name')
quantity = request.POST.get('quantity')
supplier_name = request.POST.get('supplier_name')
procurement_staff = request.POST.get('procurement_staff')
add_date = request.POST.get('add_date')
mod_date = request.POST.get('mod_date')
qs_filter = MeatOrder.objects.raw(
order_number=order_number,
product_name=product_name,
quantity=quantity,
supplier_name=supplier_name,
procurement_staff=procurement_staff,
add_date=add_date,
mod_date=mod_date,
)
context = {
'qs_filter': qs_filter,
}
return render(request, 'meatOrder/index.html', context)
else:
qs = MeatOrder.objects.all()
context = {
'queryset': qs,
}
return render(request, 'meatOrder/index.html', context)

--

--

--

既然活著就好好善用自己僅存功能向前行,舒適圈是給死人待的,像我這種人不配擁有。

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

READ/DOWNLOAD%* C Programming Language, 2nd Editio

My Experience of Web App Testing with Cypress

Install MiniKube in windows with Docker Driver

Getting waveform data with flutter and FFmpeg

How we build microservices locally, scaling docker-compose

Job Scraping Stack Overflow

HTML5 Speech Recognition API

Coding for Carrots: An Educational Critique

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
evenPig999

evenPig999

既然活著就好好善用自己僅存功能向前行,舒適圈是給死人待的,像我這種人不配擁有。

More from Medium

Tokenization of Watches — A true safe haven?

The Kluender’s Vacations

Introducing the concept of Social Proof Auditing

4 Main Reasons Most Guys Like Shy Ladies