def AddCartHandler(request): art_id = int(request.GET.get('id', 0)) print(f"AddCartHandler, art_id:{art_id}") product = Art.objects.get(id=art_id) user = request.session.get("muser") Cart.add_product(product, user) return ViewCartHandler(request)
def AddCartHandler(request): art_id = int(request.GET.get("id", 0)) if art_id == 0: return HttpResponseRedirect("/art/index") product = Art.objects.get(id=art_id) user = request.session.get("muser") Cart.add_product(product, user) return ViewCartHandler(request)
def ViewCartHandler(request): user = request.session.get("muser") (total_price, product_list) = Cart.get_products(user) context = dict( user=user, total_price=total_price, product_list=product_list, ) return render(request, "view_cart.html", context=context)
def CartOrderHandler(request): user = request.session.get("muser") (total_price, product_list) = Cart.get_products(user) order_form = forms.OrderForms() context = dict( user=user, total_price=total_price, product_list=product_list, form=order_form, ) return render(request, "product_order.html", context=context)