nagasurendra commited on
Commit
757c081
·
verified ·
1 Parent(s): d7eda21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -123,6 +123,7 @@ def generate_custom_dish():
123
  existing_cart_item_query = f"SELECT Id, Name, Quantity__c, Price__c, Base_Price__c FROM Cart_Item__c WHERE Customer_Email__c = '{email}' AND Name = '{dish_name}'"
124
  existing_cart_item_result = sf.query(existing_cart_item_query)
125
 
 
126
  if existing_cart_item_result['totalSize'] > 0:
127
  # If the cart item exists, update the quantity and price
128
  existing_cart_item = existing_cart_item_result['records'][0]
@@ -131,16 +132,16 @@ def generate_custom_dish():
131
 
132
  # Update the cart item with new quantity and price
133
  updated_cart_item = {
134
- 'Id': existing_cart_item['Id'],
135
  'Quantity__c': new_quantity,
136
  'Price__c': new_price
137
  }
138
 
139
  # Update the existing Cart_Item__c record in Salesforce
140
- cart_update_result = sf.Cart_Item__c.update(updated_cart_item)
141
 
142
  if not cart_update_result.get('success'):
143
  return jsonify({"success": False, "error": "Failed to update cart item in Salesforce"}), 500
 
144
  else:
145
  # If the cart item does not exist, create a new one
146
  cart_item = {
 
123
  existing_cart_item_query = f"SELECT Id, Name, Quantity__c, Price__c, Base_Price__c FROM Cart_Item__c WHERE Customer_Email__c = '{email}' AND Name = '{dish_name}'"
124
  existing_cart_item_result = sf.query(existing_cart_item_query)
125
 
126
+ # If the cart item exists, update the quantity and price
127
  if existing_cart_item_result['totalSize'] > 0:
128
  # If the cart item exists, update the quantity and price
129
  existing_cart_item = existing_cart_item_result['records'][0]
 
132
 
133
  # Update the cart item with new quantity and price
134
  updated_cart_item = {
 
135
  'Quantity__c': new_quantity,
136
  'Price__c': new_price
137
  }
138
 
139
  # Update the existing Cart_Item__c record in Salesforce
140
+ cart_update_result = sf.Cart_Item__c.update(existing_cart_item['Id'], updated_cart_item)
141
 
142
  if not cart_update_result.get('success'):
143
  return jsonify({"success": False, "error": "Failed to update cart item in Salesforce"}), 500
144
+
145
  else:
146
  # If the cart item does not exist, create a new one
147
  cart_item = {