Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -143,38 +143,39 @@ def submit_customization_ingredients():
|
|
| 143 |
|
| 144 |
try:
|
| 145 |
if items: # Cart submission
|
| 146 |
-
ingredient_name = f"Order_{datetime.now().strftime('%Y%m%d')}_{uuid.uuid4().hex[:8]}"
|
| 147 |
for item in items:
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
'Ingredient_Name__c': ingredient_name,
|
| 153 |
-
'Category__c': item.get('veg_nonveg', ''),
|
| 154 |
-
'Description__c': description,
|
| 155 |
-
'Image_URL__c': item.get('image_url', ''),
|
| 156 |
'Quantity__c': 1,
|
| 157 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
})
|
| 159 |
-
logger.debug(f"Submitted {len(items)} items
|
| 160 |
return jsonify({"success": True, "message": f"Submitted {len(items)} items"})
|
|
|
|
| 161 |
elif menu_item: # Single item customization
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
sf.Ingredient_Object__c.create({
|
| 167 |
-
'Ingredient_Name__c': ingredient_name,
|
| 168 |
-
'Category__c': menu_item.get('veg_nonveg', ''),
|
| 169 |
-
'Description__c': description,
|
| 170 |
-
'Image_URL__c': menu_item.get('image_url', ''),
|
| 171 |
'Quantity__c': 1,
|
| 172 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
})
|
| 174 |
-
logger.debug(f"Submitted customization for {menu_item['name']}")
|
| 175 |
return jsonify({"success": True, "message": "Customization submitted"})
|
|
|
|
| 176 |
else:
|
| 177 |
return jsonify({"error": "No items or menu item provided"}), 400
|
|
|
|
| 178 |
except Exception as e:
|
| 179 |
logger.error(f"Failed to submit: {str(e)}")
|
| 180 |
return jsonify({"error": f"Failed to submit: {str(e)}"}), 500
|
|
|
|
| 143 |
|
| 144 |
try:
|
| 145 |
if items: # Cart submission
|
|
|
|
| 146 |
for item in items:
|
| 147 |
+
ingredient_names = ', '.join(i['name'] for i in item.get('ingredients', [])) if item.get('ingredients') else ''
|
| 148 |
+
sf.Cart_Item__c.create({
|
| 149 |
+
'Name': item['name'],
|
| 150 |
+
'Base_Price__c': item.get('price', 0.0),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
'Quantity__c': 1,
|
| 152 |
+
'Add_Ons__c': ingredient_names,
|
| 153 |
+
'Add_Ons_Price__c': 0,
|
| 154 |
+
'Image1__c': item.get('image_url', ''),
|
| 155 |
+
|
| 156 |
+
'Instructions__c': item.get('instructions', '')
|
| 157 |
})
|
| 158 |
+
logger.debug(f"Submitted {len(items)} items to Cart_Item__c")
|
| 159 |
return jsonify({"success": True, "message": f"Submitted {len(items)} items"})
|
| 160 |
+
|
| 161 |
elif menu_item: # Single item customization
|
| 162 |
+
ingredient_names = ', '.join(i['name'] for i in ingredients) if ingredients else ''
|
| 163 |
+
sf.Cart_Item__c.create({
|
| 164 |
+
'Name': menu_item['name'],
|
| 165 |
+
'Base_Price__c': menu_item.get('price', 0.0),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
'Quantity__c': 1,
|
| 167 |
+
'Add_Ons__c': ingredient_names,
|
| 168 |
+
'Add_Ons_Price__c': 0,
|
| 169 |
+
'Image1__c': menu_item.get('image_url', ''),
|
| 170 |
+
|
| 171 |
+
'Instructions__c': instructions
|
| 172 |
})
|
| 173 |
+
logger.debug(f"Submitted customization for {menu_item['name']} to Cart_Item__c")
|
| 174 |
return jsonify({"success": True, "message": "Customization submitted"})
|
| 175 |
+
|
| 176 |
else:
|
| 177 |
return jsonify({"error": "No items or menu item provided"}), 400
|
| 178 |
+
|
| 179 |
except Exception as e:
|
| 180 |
logger.error(f"Failed to submit: {str(e)}")
|
| 181 |
return jsonify({"error": f"Failed to submit: {str(e)}"}), 500
|