Spaces:
Runtime error
Runtime error
| from flask import Blueprint, render_template, request, session, jsonify # Added jsonify import | |
| from salesforce import get_salesforce_connection | |
| order_blueprint = Blueprint('order', __name__) | |
| # Initialize Salesforce connection | |
| sf = get_salesforce_connection() | |
| def order_summary(): | |
| email = session.get('user_email') # Fetch logged-in user's email | |
| if not email: | |
| return redirect(url_for("login")) | |
| try: | |
| # Fetch the most recent order for the user | |
| result = sf.query(f""" | |
| SELECT Id, Customer_Name__c, Customer_Email__c, Total_Amount__c, Order_Details__c, Order_Status__c, Discount__c, Total_Bill__c | |
| FROM Order__c | |
| WHERE Customer_Email__c = '{email}' | |
| ORDER BY CreatedDate DESC | |
| LIMIT 1 | |
| """) | |
| order = result.get("records", [])[0] if result.get("records") else None | |
| if not order: | |
| return render_template("order.html", order=None) | |
| return render_template("order.html", order=order) | |
| except Exception as e: | |
| print(f"Error fetching order details: {str(e)}") | |
| return render_template("order.html", order=None, error=str(e)) |