nagasurendra commited on
Commit
ea42d98
·
verified ·
1 Parent(s): 8273a71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -60,20 +60,37 @@ def order_history():
60
  return redirect(url_for("login")) # If not logged in, redirect to login
61
 
62
  try:
 
 
 
 
 
 
63
  # Fetch order records for the logged-in user
64
  result = sf.query(f"""
65
  SELECT Id, Order_Details__c, Total_Amount__c, Discount__c, Total_Bill__c, CreatedDate
66
  FROM Order__c
67
- WHERE Customer_Email__c = '{email}'
68
  ORDER BY CreatedDate DESC
69
  LIMIT 5
70
  """)
71
 
 
 
72
  orders = result.get("records", []) # Get the order records (max 5)
73
 
 
 
 
 
 
 
74
  # Process the order details to split each line into individual items
75
  for order in orders:
76
- order['items'] = order['Order_Details__c'].split('\n') # Split the order details into lines/items
 
 
 
77
 
78
  return render_template("order_history.html", orders=orders) # Pass to template
79
 
@@ -82,6 +99,7 @@ def order_history():
82
  return render_template("order_history.html", orders=[], error=str(e))
83
 
84
 
 
85
  @app.route("/signup", methods=["GET", "POST"])
86
  def signup():
87
  if request.method == "POST":
 
60
  return redirect(url_for("login")) # If not logged in, redirect to login
61
 
62
  try:
63
+ # Sanitize email by stripping spaces and converting to lowercase
64
+ email = email.strip().lower()
65
+
66
+ # Log the email to check if it's being retrieved properly
67
+ print(f"Fetching orders for email: {email}")
68
+
69
  # Fetch order records for the logged-in user
70
  result = sf.query(f"""
71
  SELECT Id, Order_Details__c, Total_Amount__c, Discount__c, Total_Bill__c, CreatedDate
72
  FROM Order__c
73
+ WHERE LOWER(Customer_Email__c) = '{email}' # Make email comparison case-insensitive
74
  ORDER BY CreatedDate DESC
75
  LIMIT 5
76
  """)
77
 
78
+ print(f"Query result: {result}") # Log the query result
79
+
80
  orders = result.get("records", []) # Get the order records (max 5)
81
 
82
+ # Check if orders are returned and log them
83
+ if orders:
84
+ print(f"Found {len(orders)} orders for email {email}.")
85
+ else:
86
+ print(f"No orders found for email {email}.")
87
+
88
  # Process the order details to split each line into individual items
89
  for order in orders:
90
+ if order.get('Order_Details__c'):
91
+ order['items'] = order['Order_Details__c'].split('\n') # Split the order details into lines/items
92
+ else:
93
+ order['items'] = [] # If no details, set items to empty list
94
 
95
  return render_template("order_history.html", orders=orders) # Pass to template
96
 
 
99
  return render_template("order_history.html", orders=[], error=str(e))
100
 
101
 
102
+
103
  @app.route("/signup", methods=["GET", "POST"])
104
  def signup():
105
  if request.method == "POST":