How to add a discount code

How to add a discount code

In this support article we'll answer...
  1. How to add a discount code  
  2. Key security steps to ensure bots don't figure out and post codes.  

How to add a discount code

Step 1
A.  Create a calculation: HashHere
B.  Use this expression: hash(#DISCOUNT_CODE_DELETE_ME)
(A hash is a key security step)

Step 2
A.  Create a calculation: {DiscountCodeValue}
B.  This expression should calculate the discount's value.  It can be a number, constant or another calculation.
Examples
If you have a $50 discount: 50
If you've created a constant: #DISCOUNT_CODE_CONST
If your discount is 10% off our membership fees: {MembershipFeeTotal}*0.1
If your discount is 5% off all fees: {TotalFeesPriorToDiscount}*0.05

Step 3
A.  Create a calculation: DiscountCodeTotal
B.  The expression will return {DiscountCodeValue} when the correct code is entered, otherwise return zero (0).  Use this exact expression: if(hash(MemberEntersCode)==#DISCOUNT_CODE_HASH ,{DiscountCodeValue},0)

Note: If you are using previous calculations, move these 3 new calculations below the previous calculations & above any future calculations.  (see step next step)  

Step 4
Use {DiscountCodeTotal} in a future calculation to subtract your fees. 
Examples
If your discount is $50 off our membership fees, amend the following subtraction to {TotalFeesWithoutProcess} :  - {DiscountCodeTotal}
If your discount is 10% off our membership fees, amend the following subtraction to {TotalFeesWithoutProcess} :  - {DiscountCodeTotal}
If your discount is 5% off all fees, amend the following subtraction to {TotalFeesAfterDiscount} :  - {DiscountCodeTotal}

Step 5
A.  Create a constant: #DISCOUNT_CODE_HASH 
B.  Value: "12345" (you will change this in a later step)
C.  Description: Enter the discount code's hash in quotes. 

Step 6
A.  Create a constant: #DISCOUNT_CODE_DELETE_ME 
B.  Value: "test" (use you're real secrete code) 
C.  Description: Enter the discount code (in quotes) your members will enter.
(Deleting this constant is a key security step in step TBD)


Step 7
A.  Create a TEXT field on your form.  MemberEntersCode
B.  Instructions: Do you have a discount code? Enter your discount code here:
C.  Label the field: Discount Code

Step 8
A.  Create a CALCRESULT FIELD on your form: ShowDiscountCodeTotal
B.  Label the field: Discount Code: $
C. Calculation Result Name: DiscountCodeTotal 
D. Decimal Places: 2 

Step 9 (optional)
A.  Create a RICHTEXTHTML FIELD.  This text will appear if an incorrect code is entered. DisplayIncorrectCodeMessage
B.  Initially Hidden is checked.
D. Hide/Unhide Calculation: {DiscountCodeTotal}==0 && strlen(MemberEntersCode)>0
E.  Enter your message:  We're sorry.  You've entered an incorrect code.  

Step 10
A.  Preview your application using the preview tab.
B.  Scroll to bottom calculations area and find: HashHere
C.  Copy (CTRL-C) the value.
D.  Go to your constant tab.
E.  Edit the constant #DISCOUNT_CODE_HASH
F.  Paste (CTRL-V) into the value.  Paste it between the quotes.
G. Click SAVE

Step 11
A.  Delete the constant: #DISCOUNT_CODE_DELETE_ME 
(Deleting this constant is a key security step)

Step 12
Test your code in the Preview Tab

Test using the wrong code.


  1. Key security steps to ensure bots don't figure out and post codes.  

Security Tips

  1. Don't skip step 1 & step 11.  These steps allow you to remove the actual code.  If your code is "test", the text "test" should not be found in any field, calculation, or constant.  
  2. Don't choose easy to guess codes.  Humans may not be able to guess SAVE 10, 5 OFF, BOARD MEMBER, etc.  However, AI and Bots can.  
  3. The more random the code, the more secure.   
  4. Change your codes often.  Redo steps 6, 10, & 11 often.