Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1160,30 +1160,30 @@ def checkout():
|
|
| 1160 |
print(f"Error during checkout: {str(e)}")
|
| 1161 |
return jsonify({"success": False, "error": str(e)})
|
| 1162 |
|
| 1163 |
-
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
|
| 1169 |
-
|
| 1170 |
-
#
|
| 1171 |
-
|
| 1172 |
-
|
| 1173 |
-
|
| 1174 |
-
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
|
| 1188 |
# @app.route("/order", methods=["GET"])
|
| 1189 |
# def order_summary():
|
|
@@ -1214,35 +1214,7 @@ def checkout():
|
|
| 1214 |
# except Exception as e:
|
| 1215 |
# print(f"Error fetching order details: {str(e)}")
|
| 1216 |
# return render_template("order.html", order=None, error=str(e))
|
| 1217 |
-
@app.route("/order", methods=["GET"])
|
| 1218 |
-
def order_summary():
|
| 1219 |
-
email = session.get('user_email') # Fetch logged-in user's email
|
| 1220 |
-
if not email:
|
| 1221 |
-
return redirect(url_for("login"))
|
| 1222 |
|
| 1223 |
-
try:
|
| 1224 |
-
# Fetch the most recent order for the user
|
| 1225 |
-
result = sf.query(f"""
|
| 1226 |
-
SELECT Id, Customer_Name__c, Customer_Email__c, Total_Amount__c, Order_Details__c, Order_Status__c, Discount__c, Total_Bill__c
|
| 1227 |
-
FROM Order__c
|
| 1228 |
-
WHERE Customer_Email__c = '{email}'
|
| 1229 |
-
ORDER BY CreatedDate DESC
|
| 1230 |
-
LIMIT 1
|
| 1231 |
-
""")
|
| 1232 |
-
order = result.get("records", [])[0] if result.get("records") else None
|
| 1233 |
-
|
| 1234 |
-
if not order:
|
| 1235 |
-
return render_template("order.html", order=None)
|
| 1236 |
-
|
| 1237 |
-
# Convert the amounts to floats and format to one decimal place
|
| 1238 |
-
order['Total_Amount__c'] = "{:.1f}".format(float(order['Total_Amount__c']))
|
| 1239 |
-
order['Discount__c'] = "{:.1f}".format(float(order['Discount__c']))
|
| 1240 |
-
order['Total_Bill__c'] = "{:.1f}".format(float(order['Total_Bill__c']))
|
| 1241 |
-
|
| 1242 |
-
return render_template("order.html", order=order)
|
| 1243 |
-
except Exception as e:
|
| 1244 |
-
print(f"Error fetching order details: {str(e)}")
|
| 1245 |
-
return render_template("order.html", order=None, error=str(e))
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
|
|
|
| 1160 |
print(f"Error during checkout: {str(e)}")
|
| 1161 |
return jsonify({"success": False, "error": str(e)})
|
| 1162 |
|
| 1163 |
+
@app.route("/order", methods=["GET"])
|
| 1164 |
+
def order_summary():
|
| 1165 |
+
email = session.get('user_email') # Fetch logged-in user's email
|
| 1166 |
+
if not email:
|
| 1167 |
+
return redirect(url_for("login"))
|
| 1168 |
|
| 1169 |
+
try:
|
| 1170 |
+
# Fetch the most recent order for the user
|
| 1171 |
+
result = sf.query(f"""
|
| 1172 |
+
SELECT Id, Customer_Name__c, Customer_Email__c, Total_Amount__c, Order_Details__c, Order_Status__c, Discount__c, Total_Bill__c
|
| 1173 |
+
FROM Order__c
|
| 1174 |
+
WHERE Customer_Email__c = '{email}'
|
| 1175 |
+
ORDER BY CreatedDate DESC
|
| 1176 |
+
LIMIT 1
|
| 1177 |
+
""")
|
| 1178 |
+
order = result.get("records", [])[0] if result.get("records") else None
|
| 1179 |
|
| 1180 |
+
if not order:
|
| 1181 |
+
return render_template("order.html", order=None)
|
| 1182 |
|
| 1183 |
+
return render_template("order.html", order=order)
|
| 1184 |
+
except Exception as e:
|
| 1185 |
+
print(f"Error fetching order details: {str(e)}")
|
| 1186 |
+
return render_template("order.html", order=None, error=str(e))
|
| 1187 |
|
| 1188 |
# @app.route("/order", methods=["GET"])
|
| 1189 |
# def order_summary():
|
|
|
|
| 1214 |
# except Exception as e:
|
| 1215 |
# print(f"Error fetching order details: {str(e)}")
|
| 1216 |
# return render_template("order.html", order=None, error=str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1218 |
|
| 1219 |
|
| 1220 |
|