Subbu1304 commited on
Commit
c0c75d5
·
verified ·
1 Parent(s): 6527e10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -46
app.py CHANGED
@@ -1160,31 +1160,6 @@ def checkout():
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():
1190
  email = session.get('user_email') # Fetch logged-in user's email
@@ -1200,33 +1175,12 @@ def order_summary():
1200
  ORDER BY CreatedDate DESC
1201
  LIMIT 1
1202
  """)
1203
-
1204
- # Debugging: Print the fetched result to check if the order is returned
1205
- print("Fetched order data:", result)
1206
-
1207
  order = result.get("records", [])[0] if result.get("records") else None
1208
 
1209
  if not order:
1210
  return render_template("order.html", order=None)
1211
 
1212
- # Debugging: Check the order values before formatting
1213
- print("Order before formatting:", order)
1214
-
1215
- # Convert the amounts to float and format them with a single decimal place
1216
- if 'Total_Amount__c' in order:
1217
- order['Total_Amount__c'] = "{:.1f}".format(float(order['Total_Amount__c']))
1218
-
1219
- if 'Discount__c' in order:
1220
- order['Discount__c'] = "{:.1f}".format(float(order['Discount__c']))
1221
-
1222
- if 'Total_Bill__c' in order:
1223
- order['Total_Bill__c'] = "{:.1f}".format(float(order['Total_Bill__c']))
1224
-
1225
- # Debugging: Check the order values after formatting
1226
- print("Order after formatting:", order)
1227
-
1228
  return render_template("order.html", order=order)
1229
-
1230
  except Exception as e:
1231
  print(f"Error fetching order details: {str(e)}")
1232
  return render_template("order.html", order=None, error=str(e))
@@ -1235,6 +1189,8 @@ def order_summary():
1235
 
1236
 
1237
 
 
 
1238
  import smtplib
1239
  from email.mime.multipart import MIMEMultipart
1240
  from email.mime.text import MIMEText
 
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
 
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))
 
1189
 
1190
 
1191
 
1192
+
1193
+
1194
  import smtplib
1195
  from email.mime.multipart import MIMEMultipart
1196
  from email.mime.text import MIMEText