When building a form using Cognito Forms, I am trying to create a discount code field that will accept 2 different codes and apply each with a different discount on the base rate.
I cannot figure out how to calculate the discount code when using more than one discount code.
E.g. : CODE1 = 15% discount
; CODE2 = 25% discount
. These discounts are applied to a selected REGISTRATIONRATE
.
I found this code for the calculation of the discount amount on the Field Setting of Price:
= CouponCode = "CODE1" ? -FullWeekendRegistration_Amount*.15 : 0
which works for one couponcode only.
What is the syntax to add the 2nd code? i.e. I want to say IF couponcode="CODE1" then apply a 15% discount to the base rate else if couponcode="CODE2" then apply a 25%.
discount to the base rate.
Best Answer
I am a developer for Cognito Forms.
The example you included was from this blog post on three ways to implement discounts in Cognito Forms.
The syntax for the discount calculation would be:
The syntax is a bit cryptic (used by JavaScript and other C languages), but generally it is:
But you can chain them together indefinitely like:
The full documentation for calculations can be found on the Cognito Forms help site.