Update menu.py
Browse files
menu.py
CHANGED
@@ -285,17 +285,19 @@ def add_to_cart():
|
|
285 |
if new_addons:
|
286 |
combined_addons = f"{combined_addons}; {new_addons}".strip("; ")
|
287 |
|
288 |
-
#
|
289 |
-
|
290 |
-
if instructions:
|
291 |
-
combined_instructions = f"{combined_instructions} | {instructions}".strip(" | ")
|
292 |
|
293 |
# Calculate total addons price
|
294 |
-
combined_addons_list = combined_addons.split("; ")
|
295 |
combined_addons_price = sum(
|
296 |
float(addon.split("($")[1][:-1]) for addon in combined_addons_list if "($" in addon
|
297 |
)
|
298 |
|
|
|
|
|
|
|
|
|
|
|
299 |
# Update the cart item in Salesforce (updating quantity)
|
300 |
sf.Cart_Item__c.update(cart_item_id, {
|
301 |
"Quantity__c": existing_quantity + quantity, # Add the selected quantity
|
@@ -339,6 +341,3 @@ def add_to_cart():
|
|
339 |
# Log the error for debugging and return a general error message
|
340 |
print(f"Error adding item to cart: {str(e)}")
|
341 |
return jsonify({"success": False, "error": "An error occurred while adding the item to the cart."}), 500
|
342 |
-
|
343 |
-
|
344 |
-
|
|
|
285 |
if new_addons:
|
286 |
combined_addons = f"{combined_addons}; {new_addons}".strip("; ")
|
287 |
|
288 |
+
# Ensure combined_addons is a non-None string before splitting
|
289 |
+
combined_addons_list = (combined_addons or "").split("; ")
|
|
|
|
|
290 |
|
291 |
# Calculate total addons price
|
|
|
292 |
combined_addons_price = sum(
|
293 |
float(addon.split("($")[1][:-1]) for addon in combined_addons_list if "($" in addon
|
294 |
)
|
295 |
|
296 |
+
# Combine existing instructions with new instructions
|
297 |
+
combined_instructions = existing_instructions
|
298 |
+
if instructions:
|
299 |
+
combined_instructions = f"{combined_instructions} | {instructions}".strip(" | ")
|
300 |
+
|
301 |
# Update the cart item in Salesforce (updating quantity)
|
302 |
sf.Cart_Item__c.update(cart_item_id, {
|
303 |
"Quantity__c": existing_quantity + quantity, # Add the selected quantity
|
|
|
341 |
# Log the error for debugging and return a general error message
|
342 |
print(f"Error adding item to cart: {str(e)}")
|
343 |
return jsonify({"success": False, "error": "An error occurred while adding the item to the cart."}), 500
|
|
|
|
|
|