Skip to content

Commit

Permalink
fix: add selected shipping to order detail
Browse files Browse the repository at this point in the history
  • Loading branch information
hoosnick committed Sep 9, 2023
1 parent 0ad6a3d commit 7905062
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions apps/shop/views/buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,26 @@

def buy_view(request, pk):
product = Product.objects.get(pk=pk)
shipping_details = ShippingDetail.objects.all()

if request.POST:
full_name = request.POST.get('fullname')
phone_number = request.POST.get('number')
wants_at = request.POST.get('date')
count = request.POST.get('how_much')
address = request.POST.get('address')
address_id = request.POST.get('address')

fields = [full_name, phone_number, wants_at, count, address]
fields = [full_name, phone_number, wants_at, count, address_id]

for field in fields:
if field is None or "":
return False

with transaction.atomic():
item = Item.objects.get(pk=pk)
item.count = count

shipping_detail = ShippingDetail.objects.create(
title=address,
price=0
)

shipping_detail = ShippingDetail.objects.get(pk=address_id)

detail = OrderDetail.objects.create(
shipping=shipping_detail
Expand All @@ -55,9 +53,9 @@ def buy_view(request, pk):

return redirect(pay_link)


context = {
"product": product
}
"product": product,
"shipping_details": shipping_details
}

return render(request, 'buy_form.html', context)

0 comments on commit 7905062

Please sign in to comment.