- Posts: 29
- Thank you received: 4
Age discount based upon age entered
- Cory S
- Topic Author
- Offline
- Junior Member
-
Less
More
6 years 3 months ago #130607
by Cory S
Age discount based upon age entered was created by Cory S
I'm posting this here to help anyone else who has the same requirement.
I wanted to have a Discount calculated based upon the age entered during registration. I'm using this for a youth/student discount. If the participant is 18 or younger, I take $15 off the registration.
So if the age entered is 1-18, the formula field needs to return -15. If the age entered is 19 or older, the formula should return 0.
Using a custom field with a Text Field, the fee formula you would enter is:
Obviously, change the 18 to whatever age you want, and the 15 to the discount amount.
The only caveat is that unless you put a Default age value, the discount will be applied when first opening the Registration form because there is no value for age. One you enter in an age, then it will update correctly.
Interesting thing I learned, is that you can use PHP math functions in that formula field, you just can't use any conditionals.
Usual disclaimer: use at your own risk, not responsible for any issues or problems or loss of revenue.
I wanted to have a Discount calculated based upon the age entered during registration. I'm using this for a youth/student discount. If the participant is 18 or younger, I take $15 off the registration.
So if the age entered is 1-18, the formula field needs to return -15. If the age entered is 19 or older, the formula should return 0.
Using a custom field with a Text Field, the fee formula you would enter is:
Code:
-min(1, floor(18.0 / [FIELD_VALUE])) * 15
Obviously, change the 18 to whatever age you want, and the 15 to the discount amount.
The only caveat is that unless you put a Default age value, the discount will be applied when first opening the Registration form because there is no value for age. One you enter in an age, then it will update correctly.
Interesting thing I learned, is that you can use PHP math functions in that formula field, you just can't use any conditionals.
Usual disclaimer: use at your own risk, not responsible for any issues or problems or loss of revenue.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
-
6 years 3 months ago #130615
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Age discount based upon age entered
Thanks Cory for sharing your solution with the community
Tuan
Tuan
Please Log in or Create an account to join the conversation.
Moderators: Tuan Pham Ngoc
Support
Documentation
Information
Copyright © 2026 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.