Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -406,15 +406,6 @@ def checkout():
|
|
406 |
details += f", Instructions: {item['Instructions__c']}"
|
407 |
order_details.append(details)
|
408 |
|
409 |
-
# Create the order in Salesforce
|
410 |
-
order_data = {
|
411 |
-
"Customer_Name__c": user_id,
|
412 |
-
"Customer_Email__c": email,
|
413 |
-
"Total_Amount__c": total_price,
|
414 |
-
"Order_Status__c": "Pending",
|
415 |
-
"Order_Details__c": "\n".join(order_details) # Store all item details
|
416 |
-
}
|
417 |
-
sf.Order__c.create(order_data)
|
418 |
|
419 |
# Fetch the current Reward_Points__c for the user
|
420 |
customer_record = sf.query(f"""
|
@@ -431,12 +422,29 @@ def checkout():
|
|
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:
|
|
|
406 |
details += f", Instructions: {item['Instructions__c']}"
|
407 |
order_details.append(details)
|
408 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
|
410 |
# Fetch the current Reward_Points__c for the user
|
411 |
customer_record = sf.query(f"""
|
|
|
422 |
# Subtract 500 points if checkbox is selected
|
423 |
if customer['Reward_Points__c'] >= 500:
|
424 |
new_reward_points = customer['Reward_Points__c'] - 500
|
425 |
+
discount=total_price * 0.10
|
426 |
+
total_bill=total_price-discount
|
427 |
+
|
428 |
else:
|
429 |
return jsonify({"success": False, "message": "Insufficient reward points to apply."})
|
430 |
else:
|
431 |
# Add 10% of the subtotal if checkbox is not selected
|
432 |
reward_points_to_add = total_price * 0.10
|
433 |
new_reward_points = customer['Reward_Points__c'] + reward_points_to_add
|
434 |
+
discount=0
|
435 |
+
total_bill=total_price
|
436 |
+
order_data = {
|
437 |
+
"Customer_Name__c": user_id,
|
438 |
+
"Customer_Email__c": email,
|
439 |
+
"Total_Amount__c": total_price,
|
440 |
+
"Discount__c": discount,
|
441 |
+
"Total_Bill__c": total_bill,
|
442 |
+
"Order_Status__c": "Pending",
|
443 |
+
"Order_Details__c": "\n".join(order_details) # Store all item details
|
444 |
+
}
|
445 |
+
|
446 |
+
# Create the order record in Salesforce
|
447 |
+
order_result = sf.Order__c.create(order_data)
|
448 |
|
449 |
# Update the Reward_Points__c field in Salesforce
|
450 |
try:
|