nagasurendra commited on
Commit
767415b
·
verified ·
1 Parent(s): 502cb33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -994,7 +994,6 @@ def update_quantity():
994
  return jsonify({"success": False, "error": str(e)}), 500
995
 
996
 
997
- from flask import redirect, url_for
998
 
999
  @app.route("/checkout", methods=["POST"])
1000
  def checkout():
@@ -1043,7 +1042,9 @@ def checkout():
1043
  has_coupons = bool(coupon_query["records"])
1044
  print(f"Has Coupons: {has_coupons}") # Debugging coupon presence check
1045
 
1046
- if selected_coupon:
 
 
1047
  # Apply 10% discount if a valid coupon is selected
1048
  discount = total_price * 0.10 # Example: 10% discount
1049
  print(f"Discount Applied: {discount}") # Debugging discount calculation
@@ -1070,8 +1071,10 @@ def checkout():
1070
  sf.Referral_Coupon__c.update(referral_coupon_id, {
1071
  "Coupon_Code__c": updated_coupons_str
1072
  })
1073
- else:
1074
- # If no coupon is selected, add reward points
 
 
1075
  reward_points_to_add = total_price * 0.10 # Example: 10% reward points
1076
  print(f"Reward Points to Add: {reward_points_to_add}") # Debugging reward points
1077
 
@@ -1145,7 +1148,7 @@ def checkout():
1145
  print(f"Deleting Cart Item: {item['Id']}") # Debugging cart item deletion
1146
  sf.Cart_Item__c.delete(item["Id"])
1147
 
1148
- # Redirect to the order summary page
1149
  return redirect(url_for('order_summary', email=email))
1150
 
1151
  except Exception as e:
 
994
  return jsonify({"success": False, "error": str(e)}), 500
995
 
996
 
 
997
 
998
  @app.route("/checkout", methods=["POST"])
999
  def checkout():
 
1042
  has_coupons = bool(coupon_query["records"])
1043
  print(f"Has Coupons: {has_coupons}") # Debugging coupon presence check
1044
 
1045
+ if selected_coupon: # If coupon is selected, apply the coupon logic
1046
+ print("Coupon Selected, Applying Discount...")
1047
+
1048
  # Apply 10% discount if a valid coupon is selected
1049
  discount = total_price * 0.10 # Example: 10% discount
1050
  print(f"Discount Applied: {discount}") # Debugging discount calculation
 
1071
  sf.Referral_Coupon__c.update(referral_coupon_id, {
1072
  "Coupon_Code__c": updated_coupons_str
1073
  })
1074
+
1075
+ else: # If no coupon is selected, apply reward points logic
1076
+ print("No Coupon Selected, Applying Reward Points...")
1077
+
1078
  reward_points_to_add = total_price * 0.10 # Example: 10% reward points
1079
  print(f"Reward Points to Add: {reward_points_to_add}") # Debugging reward points
1080
 
 
1148
  print(f"Deleting Cart Item: {item['Id']}") # Debugging cart item deletion
1149
  sf.Cart_Item__c.delete(item["Id"])
1150
 
1151
+ # Redirect to the order summary page (successful redirect)
1152
  return redirect(url_for('order_summary', email=email))
1153
 
1154
  except Exception as e: