Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -173,8 +173,8 @@ def place_order():
|
|
| 173 |
if not item_name or not quantity:
|
| 174 |
return jsonify({"error": "Item and quantity are required."}), 400
|
| 175 |
|
| 176 |
-
# Assuming `sf.Customer_Login__c` is where user login details are saved
|
| 177 |
try:
|
|
|
|
| 178 |
customer_login = sf.query(f"SELECT Id FROM Customer_Login__c WHERE Email__c = '{user_email}' LIMIT 1")
|
| 179 |
customer_id = customer_login['records'][0]['Id']
|
| 180 |
|
|
@@ -183,7 +183,7 @@ def place_order():
|
|
| 183 |
'Quantity__c': quantity,
|
| 184 |
'Customer__c': customer_id, # Linking the order to the customer by email
|
| 185 |
'Status__c': 'Pending',
|
| 186 |
-
'Total_Amount__c': calculate_total_price(item_name, quantity), #
|
| 187 |
}
|
| 188 |
|
| 189 |
order_response = sf.Order__c.create(order)
|
|
@@ -191,6 +191,7 @@ def place_order():
|
|
| 191 |
except Exception as e:
|
| 192 |
return jsonify({"error": f"Error placing the order: {str(e)}"}), 500
|
| 193 |
|
|
|
|
| 194 |
# Helper function to calculate the total price (implement as per your pricing logic)
|
| 195 |
def calculate_total_price(item_name, quantity):
|
| 196 |
item = sf.query(f"SELECT Price__c FROM Menu_Item__c WHERE Name = '{item_name}' LIMIT 1")
|
|
|
|
| 173 |
if not item_name or not quantity:
|
| 174 |
return jsonify({"error": "Item and quantity are required."}), 400
|
| 175 |
|
|
|
|
| 176 |
try:
|
| 177 |
+
# Assuming `sf.Customer_Login__c` is where user login details are saved
|
| 178 |
customer_login = sf.query(f"SELECT Id FROM Customer_Login__c WHERE Email__c = '{user_email}' LIMIT 1")
|
| 179 |
customer_id = customer_login['records'][0]['Id']
|
| 180 |
|
|
|
|
| 183 |
'Quantity__c': quantity,
|
| 184 |
'Customer__c': customer_id, # Linking the order to the customer by email
|
| 185 |
'Status__c': 'Pending',
|
| 186 |
+
'Total_Amount__c': calculate_total_price(item_name, quantity), # Implement this function to calculate the total
|
| 187 |
}
|
| 188 |
|
| 189 |
order_response = sf.Order__c.create(order)
|
|
|
|
| 191 |
except Exception as e:
|
| 192 |
return jsonify({"error": f"Error placing the order: {str(e)}"}), 500
|
| 193 |
|
| 194 |
+
|
| 195 |
# Helper function to calculate the total price (implement as per your pricing logic)
|
| 196 |
def calculate_total_price(item_name, quantity):
|
| 197 |
item = sf.query(f"SELECT Price__c FROM Menu_Item__c WHERE Name = '{item_name}' LIMIT 1")
|