Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,39 +52,32 @@ from flask import render_template
|
|
52 |
from simple_salesforce import Salesforce
|
53 |
import json
|
54 |
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
for item in items:
|
72 |
-
item_parts = item.split('|')
|
73 |
-
order_items.append({
|
74 |
-
'name': item_parts[0].strip(),
|
75 |
-
'addons': item_parts[1].strip().replace('Add-Ons:', ''),
|
76 |
-
'instructions': item_parts[2].strip().replace('Instructions:', ''),
|
77 |
-
'price': item_parts[3].strip().replace('Price:', ''),
|
78 |
-
'image': item_parts[4].strip().replace('Image:', ''),
|
79 |
-
})
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
return render_template('previous_orders.html', orders=processed_orders)
|
88 |
|
89 |
|
90 |
@app.route("/signup", methods=["GET", "POST"])
|
|
|
52 |
from simple_salesforce import Salesforce
|
53 |
import json
|
54 |
|
55 |
+
@app.route("/order-history")
|
56 |
+
def order_history():
|
57 |
+
email = session.get('user_email') # Get the logged-in user's email
|
58 |
|
59 |
+
if not email:
|
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, Customer_Name__c, Customer_Email__c, Total_Amount__c,
|
66 |
+
Order_Details__c, Order_Status__c, Discount__c, Total_Bill__c, CreatedDate
|
67 |
+
FROM Order__c
|
68 |
+
WHERE Customer_Email__c = '{email}'
|
69 |
+
ORDER BY CreatedDate DESC
|
70 |
+
LIMIT 5
|
71 |
+
""")
|
72 |
+
|
73 |
+
orders = result.get("records", []) # Get the order records (max 5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
+
return render_template("order_history.html", orders=orders) # Pass to template
|
76 |
+
|
77 |
+
except Exception as e:
|
78 |
+
print(f"Error fetching order history: {str(e)}")
|
79 |
+
return render_template("order_history.html", orders=[], error=str(e))
|
80 |
+
|
|
|
81 |
|
82 |
|
83 |
@app.route("/signup", methods=["GET", "POST"])
|