nagasurendra commited on
Commit
f7faab4
·
verified ·
1 Parent(s): 46a4f8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -12
app.py CHANGED
@@ -145,34 +145,48 @@ def submit_customization_ingredients():
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
 
@@ -180,5 +194,6 @@ def submit_customization_ingredients():
180
  logger.error(f"Failed to submit: {str(e)}")
181
  return jsonify({"error": f"Failed to submit: {str(e)}"}), 500
182
 
 
183
  if __name__ == '__main__':
184
  app.run(debug=True, host='0.0.0.0', port=7860)
 
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
+ base_price = item.get('price', 0.0)
149
+ quantity = 1
150
+ addons_price = 0
151
+ total_price = (base_price * quantity) + addons_price
152
+
153
  sf.Cart_Item__c.create({
154
  'Name': item['name'],
155
+ 'Base_Price__c': base_price,
156
+ 'Quantity__c': quantity,
157
  'Add_Ons__c': ingredient_names,
158
+ 'Add_Ons_Price__c': addons_price,
159
+ 'Price__c': total_price,
160
  'Image1__c': item.get('image_url', ''),
161
+ 'Instructions__c': item.get('instructions', ''),
162
+ 'Category__c': item.get('veg_nonveg', ''),
163
+ 'Section__c': item.get('section', '')
164
  })
165
  logger.debug(f"Submitted {len(items)} items to Cart_Item__c")
166
  return jsonify({"success": True, "message": f"Submitted {len(items)} items"})
167
+
168
  elif menu_item: # Single item customization
169
  ingredient_names = ', '.join(i['name'] for i in ingredients) if ingredients else ''
170
+ base_price = menu_item.get('price', 0.0)
171
+ quantity = 1
172
+ addons_price = 0
173
+ total_price = (base_price * quantity) + addons_price
174
+
175
  sf.Cart_Item__c.create({
176
  'Name': menu_item['name'],
177
+ 'Base_Price__c': base_price,
178
+ 'Quantity__c': quantity,
179
  'Add_Ons__c': ingredient_names,
180
+ 'Add_Ons_Price__c': addons_price,
181
+ 'Price__c': total_price,
182
  'Image1__c': menu_item.get('image_url', ''),
183
+ 'Instructions__c': instructions,
184
+ 'Category__c': menu_item.get('veg_nonveg', ''),
185
+ 'Section__c': menu_item.get('section', '')
186
  })
187
  logger.debug(f"Submitted customization for {menu_item['name']} to Cart_Item__c")
188
  return jsonify({"success": True, "message": "Customization submitted"})
189
+
190
  else:
191
  return jsonify({"error": "No items or menu item provided"}), 400
192
 
 
194
  logger.error(f"Failed to submit: {str(e)}")
195
  return jsonify({"error": f"Failed to submit: {str(e)}"}), 500
196
 
197
+
198
  if __name__ == '__main__':
199
  app.run(debug=True, host='0.0.0.0', port=7860)