Rammohan0504 commited on
Commit
7af850f
·
verified ·
1 Parent(s): 540b915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -558,12 +558,29 @@ def order_summary():
558
  if not order:
559
  return render_template("order.html", order=None)
560
 
561
- return render_template("order.html", order=order)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
  except Exception as e:
563
  print(f"Error fetching order details: {str(e)}")
564
  return render_template("order.html", order=None, error=str(e))
565
 
566
 
567
 
 
568
  if __name__ == "__main__":
569
  app.run(debug=False, host="0.0.0.0", port=7860)
 
558
  if not order:
559
  return render_template("order.html", order=None)
560
 
561
+ # Fetch the applied coupon codes for the user
562
+ coupon_result = sf.query(f"""
563
+ SELECT Coupon_Code__c, Discount__c
564
+ FROM Referral_Coupon__c
565
+ WHERE Customer_Email__c = '{email}' AND Coupon_Status__c = 'Active'
566
+ """)
567
+
568
+ discount = 0.0
569
+ if coupon_result['records']:
570
+ coupon = coupon_result['records'][0]
571
+ discount = coupon.get('Discount__c', 0.0) # Assuming Discount__c is a custom field for discount
572
+
573
+ # Calculate the final total after applying discount
574
+ final_total = order['Total_Amount__c'] - discount # Final price after discount
575
+
576
+ return render_template("order.html", order=order, discount=discount, final_total=final_total)
577
+
578
  except Exception as e:
579
  print(f"Error fetching order details: {str(e)}")
580
  return render_template("order.html", order=None, error=str(e))
581
 
582
 
583
 
584
+
585
  if __name__ == "__main__":
586
  app.run(debug=False, host="0.0.0.0", port=7860)