Update app.py
Browse files
app.py
CHANGED
|
@@ -424,15 +424,19 @@ def checkout():
|
|
| 424 |
customer = customer_record.get("records", [])[0] if customer_record else None
|
| 425 |
|
| 426 |
if customer:
|
| 427 |
-
#
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
|
| 437 |
# Update the Reward_Points__c field in Salesforce
|
| 438 |
try:
|
|
@@ -453,6 +457,7 @@ def checkout():
|
|
| 453 |
return jsonify({"success": False, "error": str(e)})
|
| 454 |
|
| 455 |
|
|
|
|
| 456 |
@app.route("/order", methods=["GET"])
|
| 457 |
def order_summary():
|
| 458 |
email = session.get('user_email') # Fetch logged-in user's email
|
|
|
|
| 424 |
customer = customer_record.get("records", [])[0] if customer_record else None
|
| 425 |
|
| 426 |
if customer:
|
| 427 |
+
# Get the checkbox status from the frontend
|
| 428 |
+
use_reward_points = request.json.get("useRewardPoints", False)
|
| 429 |
+
|
| 430 |
+
if use_reward_points:
|
| 431 |
+
# Subtract 500 points if checkbox is selected
|
| 432 |
+
if customer['Reward_Points__c'] >= 500:
|
| 433 |
+
new_reward_points = customer['Reward_Points__c'] - 500
|
| 434 |
+
else:
|
| 435 |
+
return jsonify({"success": False, "message": "Insufficient reward points to apply."})
|
| 436 |
+
else:
|
| 437 |
+
# Add 10% of the subtotal if checkbox is not selected
|
| 438 |
+
reward_points_to_add = total_price * 0.10
|
| 439 |
+
new_reward_points = customer['Reward_Points__c'] + reward_points_to_add
|
| 440 |
|
| 441 |
# Update the Reward_Points__c field in Salesforce
|
| 442 |
try:
|
|
|
|
| 457 |
return jsonify({"success": False, "error": str(e)})
|
| 458 |
|
| 459 |
|
| 460 |
+
|
| 461 |
@app.route("/order", methods=["GET"])
|
| 462 |
def order_summary():
|
| 463 |
email = session.get('user_email') # Fetch logged-in user's email
|