Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1185,6 +1185,35 @@ def checkout():
|
|
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():
|
1190 |
email = session.get('user_email') # Fetch logged-in user's email
|
@@ -1205,10 +1234,10 @@ def order_summary():
|
|
1205 |
if not order:
|
1206 |
return render_template("order.html", order=None)
|
1207 |
|
1208 |
-
# Convert
|
1209 |
-
order['Total_Amount__c'] =
|
1210 |
-
order['Discount__c'] =
|
1211 |
-
order['Total_Bill__c'] =
|
1212 |
|
1213 |
return render_template("order.html", order=order)
|
1214 |
except Exception as e:
|
@@ -1217,6 +1246,7 @@ def order_summary():
|
|
1217 |
|
1218 |
|
1219 |
|
|
|
1220 |
import smtplib
|
1221 |
from email.mime.multipart import MIMEMultipart
|
1222 |
from email.mime.text import MIMEText
|
|
|
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():
|
1190 |
+
# email = session.get('user_email') # Fetch logged-in user's email
|
1191 |
+
# if not email:
|
1192 |
+
# return redirect(url_for("login"))
|
1193 |
+
|
1194 |
+
# try:
|
1195 |
+
# # Fetch the most recent order for the user
|
1196 |
+
# result = sf.query(f"""
|
1197 |
+
# SELECT Id, Customer_Name__c, Customer_Email__c, Total_Amount__c, Order_Details__c, Order_Status__c, Discount__c, Total_Bill__c
|
1198 |
+
# FROM Order__c
|
1199 |
+
# WHERE Customer_Email__c = '{email}'
|
1200 |
+
# ORDER BY CreatedDate DESC
|
1201 |
+
# LIMIT 1
|
1202 |
+
# """)
|
1203 |
+
# order = result.get("records", [])[0] if result.get("records") else None
|
1204 |
+
|
1205 |
+
# if not order:
|
1206 |
+
# return render_template("order.html", order=None)
|
1207 |
+
|
1208 |
+
# # Convert prices to integers
|
1209 |
+
# order['Total_Amount__c'] = int(float(order['Total_Amount__c']))
|
1210 |
+
# order['Discount__c'] = int(float(order['Discount__c']))
|
1211 |
+
# order['Total_Bill__c'] = int(float(order['Total_Bill__c']))
|
1212 |
+
|
1213 |
+
# return render_template("order.html", order=order)
|
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
|
|
|
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:
|
|
|
1246 |
|
1247 |
|
1248 |
|
1249 |
+
|
1250 |
import smtplib
|
1251 |
from email.mime.multipart import MIMEMultipart
|
1252 |
from email.mime.text import MIMEText
|