Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1003,16 +1003,20 @@ def checkout():
|
|
| 1003 |
return jsonify({"success": False, "message": "User not logged in"})
|
| 1004 |
|
| 1005 |
try:
|
|
|
|
| 1006 |
data = request.json
|
| 1007 |
selected_coupon = data.get("selectedCoupon", "").strip() # Get selected coupon
|
| 1008 |
|
| 1009 |
-
# Fetch cart items
|
| 1010 |
result = sf.query(f"""
|
| 1011 |
SELECT Id, Name, Price__c, Add_Ons_Price__c, Quantity__c, Add_Ons__c, Instructions__c, Image1__c
|
| 1012 |
FROM Cart_Item__c
|
| 1013 |
WHERE Customer_Email__c = '{email}'
|
| 1014 |
""")
|
|
|
|
|
|
|
| 1015 |
cart_items = result.get("records", [])
|
|
|
|
| 1016 |
|
| 1017 |
if not cart_items:
|
| 1018 |
return jsonify({"success": False, "message": "Cart is empty"})
|
|
@@ -1114,6 +1118,7 @@ def checkout():
|
|
| 1114 |
print(f"Error during checkout: {str(e)}")
|
| 1115 |
return jsonify({"success": False, "error": str(e)})
|
| 1116 |
|
|
|
|
| 1117 |
@app.route("/order", methods=["GET"])
|
| 1118 |
def order_summary():
|
| 1119 |
email = session.get('user_email') # Fetch logged-in user's email
|
|
|
|
| 1003 |
return jsonify({"success": False, "message": "User not logged in"})
|
| 1004 |
|
| 1005 |
try:
|
| 1006 |
+
# Fetch the selected coupon (if any)
|
| 1007 |
data = request.json
|
| 1008 |
selected_coupon = data.get("selectedCoupon", "").strip() # Get selected coupon
|
| 1009 |
|
| 1010 |
+
# Fetch cart items for the current user
|
| 1011 |
result = sf.query(f"""
|
| 1012 |
SELECT Id, Name, Price__c, Add_Ons_Price__c, Quantity__c, Add_Ons__c, Instructions__c, Image1__c
|
| 1013 |
FROM Cart_Item__c
|
| 1014 |
WHERE Customer_Email__c = '{email}'
|
| 1015 |
""")
|
| 1016 |
+
|
| 1017 |
+
# Log the cart items to see if they are fetched correctly
|
| 1018 |
cart_items = result.get("records", [])
|
| 1019 |
+
print(f"Cart Items Retrieved: {cart_items}") # Debugging log
|
| 1020 |
|
| 1021 |
if not cart_items:
|
| 1022 |
return jsonify({"success": False, "message": "Cart is empty"})
|
|
|
|
| 1118 |
print(f"Error during checkout: {str(e)}")
|
| 1119 |
return jsonify({"success": False, "error": str(e)})
|
| 1120 |
|
| 1121 |
+
|
| 1122 |
@app.route("/order", methods=["GET"])
|
| 1123 |
def order_summary():
|
| 1124 |
email = session.get('user_email') # Fetch logged-in user's email
|