nagasurendra commited on
Commit
27affce
Β·
verified Β·
1 Parent(s): 006cdd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -86
app.py CHANGED
@@ -1097,7 +1097,7 @@ def checkout():
1097
  # βœ… Delete cart items after order is placed
1098
  for item in cart_items:
1099
  sf.Cart_Item__c.delete(item["Id"])
1100
- send_order_email(email, order_data)
1101
 
1102
 
1103
  return jsonify({"success": True, "message": "Order placed successfully!"})
@@ -1133,92 +1133,7 @@ import smtplib
1133
  from email.mime.multipart import MIMEMultipart
1134
  from email.mime.text import MIMEText
1135
 
1136
- def send_order_email(email, order):
1137
- restaurant_name = "Your Restaurant Name"
1138
- subject = f"Your Order Confirmation from {restaurant_name}"
1139
-
1140
- # Email content
1141
- message = f"""
1142
- <html>
1143
- <body>
1144
- <h2>Hello {order['Customer_Name__c']},</h2>
1145
- <p>Thank you for placing your order with <b>{restaurant_name}!</b> Below are the details of your order:</p>
1146
-
1147
- <h3>πŸ›’ Order Summary</h3>
1148
- <p><b>Order ID:</b> {order['Id']}<br>
1149
- <b>Customer Name:</b> {order['Customer_Name__c']}<br>
1150
- <b>Email:</b> {order['Customer_Email__c']}<br>
1151
- <b>Order Status:</b> {order['Order_Status__c']}</p>
1152
-
1153
- <h3>🍽️ Items Ordered</h3>
1154
- <table border="1" cellpadding="5" cellspacing="0">
1155
- <tr>
1156
- <th>Item Name</th>
1157
- <th>Quantity</th>
1158
- <th>Add-Ons</th>
1159
- <th>Instructions</th>
1160
- <th>Price</th>
1161
- </tr>
1162
- """
1163
-
1164
- # Adding items dynamically
1165
- for item in order["Order_Details__c"].split("\n"):
1166
- parts = item.split("|")
1167
- if len(parts) == 5:
1168
- message += f"""
1169
- <tr>
1170
- <td>{parts[0]}</td>
1171
- <td>{parts[1]}</td>
1172
- <td>{parts[2]}</td>
1173
- <td>{parts[3]}</td>
1174
- <td>{parts[4]}</td>
1175
- </tr>
1176
- """
1177
-
1178
- message += f"""
1179
- </table>
1180
-
1181
- <h3>πŸ’° Billing Details</h3>
1182
- <p><b>Total Amount:</b> ${order['Total_Amount__c']}<br>
1183
- <b>Discount Applied:</b> ${order['Discount__c']}<br>
1184
- <b>Final Bill:</b> <b>${order['Total_Bill__c']}</b></p>
1185
-
1186
- <p>πŸ•’ <b>Your order is currently:</b> <i>{order['Order_Status__c']}</i><br>
1187
- πŸ“ <b>Estimated Delivery Time:</b> [Estimated_Delivery_Time]</p>
1188
-
1189
- <hr>
1190
- <p>If you have any questions regarding your order, feel free to contact us at <b>[Restaurant Support Email]</b>.</p>
1191
-
1192
- <p>Looking forward to serving you!</p>
1193
-
1194
- <h3>🍴 {restaurant_name}</h3>
1195
- <p>πŸ“ [Restaurant Address]<br>
1196
- πŸ“ž [Restaurant Phone]</p>
1197
- </body>
1198
- </html>
1199
- """
1200
-
1201
- # Email sending configuration
1202
- sender_email = "[email protected]"
1203
- sender_password = "yourpassword"
1204
- recipient_email = email
1205
-
1206
- msg = MIMEMultipart()
1207
- msg["From"] = sender_email
1208
- msg["To"] = recipient_email
1209
- msg["Subject"] = subject
1210
-
1211
- msg.attach(MIMEText(message, "html"))
1212
 
1213
- try:
1214
- server = smtplib.SMTP("smtp.gmail.com", 587) # Change for your email provider
1215
- server.starttls()
1216
- server.login(sender_email, sender_password)
1217
- server.sendmail(sender_email, recipient_email, msg.as_string())
1218
- server.quit()
1219
- print(f"Order email sent successfully to {email}")
1220
- except Exception as e:
1221
- print(f"Error sending email: {str(e)}")
1222
 
1223
 
1224
  if __name__ == "__main__":
 
1097
  # βœ… Delete cart items after order is placed
1098
  for item in cart_items:
1099
  sf.Cart_Item__c.delete(item["Id"])
1100
+
1101
 
1102
 
1103
  return jsonify({"success": True, "message": "Order placed successfully!"})
 
1133
  from email.mime.multipart import MIMEMultipart
1134
  from email.mime.text import MIMEText
1135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1136
 
 
 
 
 
 
 
 
 
 
1137
 
1138
 
1139
  if __name__ == "__main__":