Rammohan0504 commited on
Commit
f4de377
·
verified ·
1 Parent(s): 9474a2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -623,6 +623,30 @@ def checkout():
623
  print(f"Error during checkout: {str(e)}")
624
  return jsonify({"success": False, "error": str(e)})
625
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
 
627
  @app.route("/order", methods=["GET"])
628
  def order_summary():
 
623
  print(f"Error during checkout: {str(e)}")
624
  return jsonify({"success": False, "error": str(e)})
625
 
626
+ @app.route("/order-history", methods=["GET"])
627
+ def order_history():
628
+ email = session.get('user_email') # Get logged-in user's email
629
+ if not email:
630
+ return redirect(url_for("login"))
631
+
632
+ try:
633
+ # Fetch past orders for the user
634
+ result = sf.query(f"""
635
+ SELECT Id, Customer_Name__c, Customer_Email__c, Total_Amount__c,
636
+ Order_Details__c, Order_Status__c, Discount__c, Total_Bill__c, CreatedDate
637
+ FROM Order__c
638
+ WHERE Customer_Email__c = '{email}'
639
+ ORDER BY CreatedDate DESC
640
+ """)
641
+
642
+ orders = result.get("records", []) # Fetch all orders
643
+
644
+ return render_template("order_history.html", orders=orders)
645
+
646
+ except Exception as e:
647
+ print(f"Error fetching order history: {str(e)}")
648
+ return render_template("order_history.html", orders=[], error=str(e))
649
+
650
 
651
  @app.route("/order", methods=["GET"])
652
  def order_summary():