Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -993,6 +993,8 @@ def update_quantity():
|
|
| 993 |
print(f"Error updating quantity: {str(e)}")
|
| 994 |
return jsonify({"success": False, "error": str(e)}), 500
|
| 995 |
|
|
|
|
|
|
|
| 996 |
@app.route("/checkout", methods=["POST"])
|
| 997 |
def checkout():
|
| 998 |
email = session.get('user_email')
|
|
@@ -1107,8 +1109,9 @@ def checkout():
|
|
| 1107 |
# Create the order in Salesforce
|
| 1108 |
order_response = sf.Order__c.create(order_data)
|
| 1109 |
|
| 1110 |
-
#
|
| 1111 |
if order_response:
|
|
|
|
| 1112 |
for item in cart_items:
|
| 1113 |
sf.Cart_Item__c.delete(item["Id"])
|
| 1114 |
|
|
|
|
| 993 |
print(f"Error updating quantity: {str(e)}")
|
| 994 |
return jsonify({"success": False, "error": str(e)}), 500
|
| 995 |
|
| 996 |
+
|
| 997 |
+
|
| 998 |
@app.route("/checkout", methods=["POST"])
|
| 999 |
def checkout():
|
| 1000 |
email = session.get('user_email')
|
|
|
|
| 1109 |
# Create the order in Salesforce
|
| 1110 |
order_response = sf.Order__c.create(order_data)
|
| 1111 |
|
| 1112 |
+
# Ensure the order was created successfully before deleting cart items
|
| 1113 |
if order_response:
|
| 1114 |
+
# Only delete cart items after the order is created
|
| 1115 |
for item in cart_items:
|
| 1116 |
sf.Cart_Item__c.delete(item["Id"])
|
| 1117 |
|