Update app.py
Browse files
app.py
CHANGED
|
@@ -777,6 +777,7 @@ def add_to_cart():
|
|
| 777 |
instructions = data.get('instructions', '')
|
| 778 |
category = data.get('category')
|
| 779 |
section = data.get('section')
|
|
|
|
| 780 |
customer_email = session.get('user_email')
|
| 781 |
|
| 782 |
# Basic validation for required fields
|
|
@@ -823,13 +824,13 @@ def add_to_cart():
|
|
| 823 |
float(addon.split("($")[1][:-1]) for addon in combined_addons_list if "($" in addon
|
| 824 |
)
|
| 825 |
|
| 826 |
-
# Update the cart item in Salesforce
|
| 827 |
sf.Cart_Item__c.update(cart_item_id, {
|
| 828 |
-
"Quantity__c": existing_quantity +
|
| 829 |
"Add_Ons__c": combined_addons,
|
| 830 |
"Add_Ons_Price__c": combined_addons_price,
|
| 831 |
"Instructions__c": combined_instructions,
|
| 832 |
-
"Price__c": (existing_quantity +
|
| 833 |
"Category__c": category,
|
| 834 |
"Section__c": section
|
| 835 |
})
|
|
@@ -839,14 +840,14 @@ def add_to_cart():
|
|
| 839 |
if addons:
|
| 840 |
addons_string = new_addons
|
| 841 |
|
| 842 |
-
total_price = item_price + addons_price
|
| 843 |
|
| 844 |
# Create new cart item in Salesforce
|
| 845 |
sf.Cart_Item__c.create({
|
| 846 |
"Name": item_name,
|
| 847 |
"Price__c": total_price,
|
| 848 |
"Base_Price__c": item_price,
|
| 849 |
-
"Quantity__c":
|
| 850 |
"Add_Ons_Price__c": addons_price,
|
| 851 |
"Add_Ons__c": addons_string,
|
| 852 |
"Image1__c": item_image,
|
|
|
|
| 777 |
instructions = data.get('instructions', '')
|
| 778 |
category = data.get('category')
|
| 779 |
section = data.get('section')
|
| 780 |
+
quantity = data.get('quantity', 1) # Get the quantity field from the request
|
| 781 |
customer_email = session.get('user_email')
|
| 782 |
|
| 783 |
# Basic validation for required fields
|
|
|
|
| 824 |
float(addon.split("($")[1][:-1]) for addon in combined_addons_list if "($" in addon
|
| 825 |
)
|
| 826 |
|
| 827 |
+
# Update the cart item in Salesforce (updating quantity)
|
| 828 |
sf.Cart_Item__c.update(cart_item_id, {
|
| 829 |
+
"Quantity__c": existing_quantity + quantity, # Add the selected quantity
|
| 830 |
"Add_Ons__c": combined_addons,
|
| 831 |
"Add_Ons_Price__c": combined_addons_price,
|
| 832 |
"Instructions__c": combined_instructions,
|
| 833 |
+
"Price__c": (existing_quantity + quantity) * item_price + combined_addons_price,
|
| 834 |
"Category__c": category,
|
| 835 |
"Section__c": section
|
| 836 |
})
|
|
|
|
| 840 |
if addons:
|
| 841 |
addons_string = new_addons
|
| 842 |
|
| 843 |
+
total_price = item_price * quantity + addons_price # Multiply by the quantity
|
| 844 |
|
| 845 |
# Create new cart item in Salesforce
|
| 846 |
sf.Cart_Item__c.create({
|
| 847 |
"Name": item_name,
|
| 848 |
"Price__c": total_price,
|
| 849 |
"Base_Price__c": item_price,
|
| 850 |
+
"Quantity__c": quantity, # Use the selected quantity
|
| 851 |
"Add_Ons_Price__c": addons_price,
|
| 852 |
"Add_Ons__c": addons_string,
|
| 853 |
"Image1__c": item_image,
|