Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -797,8 +797,6 @@ def checkout():
|
|
| 797 |
})
|
| 798 |
print(f"Successfully updated reward points for {email}")
|
| 799 |
|
| 800 |
-
|
| 801 |
-
|
| 802 |
total_bill = total_price - discount
|
| 803 |
|
| 804 |
# ✅ Store **all details** including Add-Ons, Instructions, Price, and Image
|
|
@@ -809,6 +807,18 @@ def checkout():
|
|
| 809 |
for item in cart_items
|
| 810 |
)
|
| 811 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 812 |
# Store the order details in Order__c
|
| 813 |
order_data = {
|
| 814 |
"Customer_Name__c": user_id,
|
|
@@ -817,7 +827,7 @@ def checkout():
|
|
| 817 |
"Discount__c": discount,
|
| 818 |
"Total_Bill__c": total_bill,
|
| 819 |
"Order_Status__c": "Pending",
|
| 820 |
-
"Customer2__c":
|
| 821 |
"Order_Details__c": order_details # ✅ Now includes **all details**
|
| 822 |
}
|
| 823 |
|
|
|
|
| 797 |
})
|
| 798 |
print(f"Successfully updated reward points for {email}")
|
| 799 |
|
|
|
|
|
|
|
| 800 |
total_bill = total_price - discount
|
| 801 |
|
| 802 |
# ✅ Store **all details** including Add-Ons, Instructions, Price, and Image
|
|
|
|
| 807 |
for item in cart_items
|
| 808 |
)
|
| 809 |
|
| 810 |
+
# Fetch Customer ID from Customer_Login__c based on email
|
| 811 |
+
customer_query = sf.query(f"""
|
| 812 |
+
SELECT Id FROM Customer_Login__c
|
| 813 |
+
WHERE Email__c = '{email}'
|
| 814 |
+
""")
|
| 815 |
+
|
| 816 |
+
# Assuming the customer exists
|
| 817 |
+
customer_id = customer_query["records"][0]["Id"] if customer_query["records"] else None
|
| 818 |
+
|
| 819 |
+
if not customer_id:
|
| 820 |
+
return jsonify({"success": False, "message": "Customer record not found in Salesforce"})
|
| 821 |
+
|
| 822 |
# Store the order details in Order__c
|
| 823 |
order_data = {
|
| 824 |
"Customer_Name__c": user_id,
|
|
|
|
| 827 |
"Discount__c": discount,
|
| 828 |
"Total_Bill__c": total_bill,
|
| 829 |
"Order_Status__c": "Pending",
|
| 830 |
+
"Customer2__c": customer_id, # Correcting to use the Salesforce Customer record ID
|
| 831 |
"Order_Details__c": order_details # ✅ Now includes **all details**
|
| 832 |
}
|
| 833 |
|