Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1107,13 +1107,13 @@ def checkout():
|
|
1107 |
@app.route('/cart/add', methods=['POST'])
|
1108 |
def add_to_cart():
|
1109 |
data = request.json
|
1110 |
-
item_name = data.get('itemName')
|
1111 |
|
1112 |
if not item_name:
|
1113 |
return jsonify({"success": False, "error": "Item name is required."}), 400
|
1114 |
|
1115 |
try:
|
1116 |
-
email = session.get('user_email')
|
1117 |
if not email:
|
1118 |
return jsonify({"success": False, "error": "User not logged in."}), 401
|
1119 |
|
@@ -1136,10 +1136,10 @@ def add_to_cart():
|
|
1136 |
'Quantity__c': 1,
|
1137 |
'Image1__c': item_image,
|
1138 |
'Customer_Email__c': email,
|
1139 |
-
'Instructions__c': '', #
|
1140 |
}
|
1141 |
|
1142 |
-
# Insert the item into the cart
|
1143 |
sf.Cart_Item__c.create(cart_item)
|
1144 |
|
1145 |
return jsonify({"success": True, "message": "Item added to cart successfully."})
|
@@ -1147,7 +1147,6 @@ def add_to_cart():
|
|
1147 |
except Exception as e:
|
1148 |
return jsonify({"success": False, "error": str(e)}), 500
|
1149 |
|
1150 |
-
|
1151 |
@app.route("/order", methods=["GET"])
|
1152 |
def order_summary():
|
1153 |
email = session.get('user_email') # Fetch logged-in user's email
|
|
|
1107 |
@app.route('/cart/add', methods=['POST'])
|
1108 |
def add_to_cart():
|
1109 |
data = request.json
|
1110 |
+
item_name = data.get('itemName') # The item name to add to cart
|
1111 |
|
1112 |
if not item_name:
|
1113 |
return jsonify({"success": False, "error": "Item name is required."}), 400
|
1114 |
|
1115 |
try:
|
1116 |
+
email = session.get('user_email') # Ensure user is logged in
|
1117 |
if not email:
|
1118 |
return jsonify({"success": False, "error": "User not logged in."}), 401
|
1119 |
|
|
|
1136 |
'Quantity__c': 1,
|
1137 |
'Image1__c': item_image,
|
1138 |
'Customer_Email__c': email,
|
1139 |
+
'Instructions__c': '', # Optionally handle user instructions
|
1140 |
}
|
1141 |
|
1142 |
+
# Insert the item into the cart in Salesforce
|
1143 |
sf.Cart_Item__c.create(cart_item)
|
1144 |
|
1145 |
return jsonify({"success": True, "message": "Item added to cart successfully."})
|
|
|
1147 |
except Exception as e:
|
1148 |
return jsonify({"success": False, "error": str(e)}), 500
|
1149 |
|
|
|
1150 |
@app.route("/order", methods=["GET"])
|
1151 |
def order_summary():
|
1152 |
email = session.get('user_email') # Fetch logged-in user's email
|