Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1068,7 +1068,7 @@ def checkout():
|
|
| 1068 |
# Final total bill calculation
|
| 1069 |
total_bill = total_price - discount
|
| 1070 |
|
| 1071 |
-
# Store all order details
|
| 1072 |
order_details = "\n".join(
|
| 1073 |
f"{item['Name']} x{item['Quantity__c']} | Add-Ons: {item.get('Add_Ons__c', 'None')} | "
|
| 1074 |
f"Instructions: {item.get('Instructions__c', 'None')} | "
|
|
@@ -1101,11 +1101,12 @@ def checkout():
|
|
| 1101 |
}
|
| 1102 |
|
| 1103 |
# Create the order in Salesforce
|
| 1104 |
-
sf.Order__c.create(order_data)
|
| 1105 |
|
| 1106 |
-
#
|
| 1107 |
-
|
| 1108 |
-
|
|
|
|
| 1109 |
|
| 1110 |
return jsonify({"success": True, "message": "Order placed successfully!", "discount": discount, "totalBill": total_bill})
|
| 1111 |
|
|
|
|
| 1068 |
# Final total bill calculation
|
| 1069 |
total_bill = total_price - discount
|
| 1070 |
|
| 1071 |
+
# Store all order details (before deleting cart items)
|
| 1072 |
order_details = "\n".join(
|
| 1073 |
f"{item['Name']} x{item['Quantity__c']} | Add-Ons: {item.get('Add_Ons__c', 'None')} | "
|
| 1074 |
f"Instructions: {item.get('Instructions__c', 'None')} | "
|
|
|
|
| 1101 |
}
|
| 1102 |
|
| 1103 |
# Create the order in Salesforce
|
| 1104 |
+
order_response = sf.Order__c.create(order_data)
|
| 1105 |
|
| 1106 |
+
# After order is placed, delete cart items
|
| 1107 |
+
if order_response:
|
| 1108 |
+
for item in cart_items:
|
| 1109 |
+
sf.Cart_Item__c.delete(item["Id"])
|
| 1110 |
|
| 1111 |
return jsonify({"success": True, "message": "Order placed successfully!", "discount": discount, "totalBill": total_bill})
|
| 1112 |
|