Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -255,6 +255,12 @@ def submit_customization_ingredients():
|
|
255 |
ingredients = data.get('ingredients', [])
|
256 |
instructions = data.get('instructions', '')
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
try:
|
259 |
if items: # Cart submission
|
260 |
for item in items:
|
@@ -264,6 +270,7 @@ def submit_customization_ingredients():
|
|
264 |
addons_price = 0
|
265 |
total_price = (base_price * quantity) + addons_price
|
266 |
|
|
|
267 |
sf.Cart_Item__c.create({
|
268 |
'Name': item['name'],
|
269 |
'Base_Price__c': base_price,
|
@@ -274,7 +281,8 @@ def submit_customization_ingredients():
|
|
274 |
'Image1__c': item.get('image_url', ''),
|
275 |
'Instructions__c': item.get('instructions', ''),
|
276 |
'Category__c': item.get('veg_nonveg', ''),
|
277 |
-
'Section__c': item.get('section', '')
|
|
|
278 |
})
|
279 |
logger.debug(f"Submitted {len(items)} items to Cart_Item__c")
|
280 |
return jsonify({"success": True, "message": f"Submitted {len(items)} items"})
|
@@ -286,6 +294,7 @@ def submit_customization_ingredients():
|
|
286 |
addons_price = 0
|
287 |
total_price = (base_price * quantity) + addons_price
|
288 |
|
|
|
289 |
sf.Cart_Item__c.create({
|
290 |
'Name': menu_item['name'],
|
291 |
'Base_Price__c': base_price,
|
@@ -296,7 +305,8 @@ def submit_customization_ingredients():
|
|
296 |
'Image1__c': menu_item.get('image_url', ''),
|
297 |
'Instructions__c': instructions,
|
298 |
'Category__c': menu_item.get('veg_nonveg', ''),
|
299 |
-
'Section__c': menu_item.get('section', '')
|
|
|
300 |
})
|
301 |
logger.debug(f"Submitted customization for {menu_item['name']} to Cart_Item__c")
|
302 |
return jsonify({"success": True, "message": "Customization submitted"})
|
@@ -308,5 +318,6 @@ def submit_customization_ingredients():
|
|
308 |
logger.error(f"Failed to submit: {str(e)}")
|
309 |
return jsonify({"error": f"Failed to submit: {str(e)}"}), 500
|
310 |
|
|
|
311 |
if __name__ == "__main__":
|
312 |
app.run(debug=True, host="0.0.0.0", port=7860)
|
|
|
255 |
ingredients = data.get('ingredients', [])
|
256 |
instructions = data.get('instructions', '')
|
257 |
|
258 |
+
# Get the session email (this should already be set during login)
|
259 |
+
customer_email = session.get('user_email')
|
260 |
+
|
261 |
+
if not customer_email:
|
262 |
+
return jsonify({"error": "User email not found in session"}), 400
|
263 |
+
|
264 |
try:
|
265 |
if items: # Cart submission
|
266 |
for item in items:
|
|
|
270 |
addons_price = 0
|
271 |
total_price = (base_price * quantity) + addons_price
|
272 |
|
273 |
+
# Create Cart_Item__c record and include Customer_Email__c
|
274 |
sf.Cart_Item__c.create({
|
275 |
'Name': item['name'],
|
276 |
'Base_Price__c': base_price,
|
|
|
281 |
'Image1__c': item.get('image_url', ''),
|
282 |
'Instructions__c': item.get('instructions', ''),
|
283 |
'Category__c': item.get('veg_nonveg', ''),
|
284 |
+
'Section__c': item.get('section', ''),
|
285 |
+
'Customer_Email__c': customer_email # Store session email
|
286 |
})
|
287 |
logger.debug(f"Submitted {len(items)} items to Cart_Item__c")
|
288 |
return jsonify({"success": True, "message": f"Submitted {len(items)} items"})
|
|
|
294 |
addons_price = 0
|
295 |
total_price = (base_price * quantity) + addons_price
|
296 |
|
297 |
+
# Create Cart_Item__c record and include Customer_Email__c
|
298 |
sf.Cart_Item__c.create({
|
299 |
'Name': menu_item['name'],
|
300 |
'Base_Price__c': base_price,
|
|
|
305 |
'Image1__c': menu_item.get('image_url', ''),
|
306 |
'Instructions__c': instructions,
|
307 |
'Category__c': menu_item.get('veg_nonveg', ''),
|
308 |
+
'Section__c': menu_item.get('section', ''),
|
309 |
+
'Customer_Email__c': customer_email # Store session email
|
310 |
})
|
311 |
logger.debug(f"Submitted customization for {menu_item['name']} to Cart_Item__c")
|
312 |
return jsonify({"success": True, "message": "Customization submitted"})
|
|
|
318 |
logger.error(f"Failed to submit: {str(e)}")
|
319 |
return jsonify({"error": f"Failed to submit: {str(e)}"}), 500
|
320 |
|
321 |
+
|
322 |
if __name__ == "__main__":
|
323 |
app.run(debug=True, host="0.0.0.0", port=7860)
|