def buynow_cart(request, itemid, userid): # Buynow button in addtocart if User.is_authenticated: login_user = User.objects.get(pk= userid) user = UserRegister.objects.get(user_email=login_user.email) ordereditem = AddToCart.objects.get(pk= itemid, cart_useremail= login_user.email) if Order.objects.filter(order_name= ordereditem.cart_name, order_useremail= login_user.email).exists(): order = Order.objects.get(order_name= ordereditem.cart_name, order_useremail= login_user.email) return render(request, "order.html", {'order': order}) else: #ordereditem = Item.objects.get(pk= itemid) order = Order() order.order_useremail = login_user.email order.order_name = ordereditem.cart_name order.order_image = ordereditem.cart_image order.order_price = ordereditem.cart_price order.order_publisher = ordereditem.cart_publisher order.order_description = ordereditem.cart_description order.order_origin = ordereditem.cart_origin order.order_phonenumber = user.user_phonenumber order.order_address = user.user_address order.save() return render(request, "order.html", {'order': order}) else: text="Please Login in to your account !!!" return render(request, 'note.html', {'text': text})
def buynow(request, itemid, userid): # Homepage BUYNOW function if User.is_authenticated: #Request paytm to add money from user account to your account login_user = User.objects.get(pk= userid) user = UserRegister.objects.get(user_email=login_user.email) orderitem = Item.objects.get(pk= itemid) if Order.objects.filter(order_name= orderitem.item_name, order_useremail= login_user.email).exists(): order = Order.objects.get(order_name= orderitem.item_name, order_useremail= login_user.email) return render(request, "order.html", {'order': order}) else: ordereditem = Item.objects.get(pk= itemid) order = Order() order.order_useremail = login_user.email order.order_name = ordereditem.item_name order.order_image = ordereditem.item_image order.order_price = ordereditem.item_price order.order_publisher = ordereditem.item_publisher order.order_description = ordereditem.item_description order.order_origin = ordereditem.item_origin order.order_phonenumber = user.user_phonenumber order.order_address = user.user_address order.save() return render(request, "order.html", {'order': order}) else: text="Please Login in to your account !!!" return render(request, 'note.html', {'text': text})