You can use optional the "Validate by Phrase" property of a text field to give a discount to users who enter the proper coupon code.
The general idea behind the "Validate by Phrase" feature is that the form user must enter in a certain word or phrase correctly into a text element in order to submit the form - if the word or phrase entered does not match the criteria set by the form admin when it was created, the user will see an error message and won't be able to submit the form for payment. The validated text element can be combined with another form element that includes a price discount. Working together, the two elements will grant a discount to any user who enters the proper validation code.
The best way to include a discount code element is to use a radio button element to first ask the user if they have a coupon code; if the user selects 'Yes,' they will be granted the discount AND prompted to enter the coupon code, which at that point becomes necessary to submit the form. If the user selects 'No,' however, no discount is granted and no coupon code is required.
Our example form is pretty simple; it just asks users to select the size t-shirt they want to buy, and then asks if they have a discount code.
The "Purchase a T-shirt" element doesn't have any particular special properties, it's just a series of radio buttons.
The "Coupon Code?" element, however, does have some special formatting applied. The green border on the Form Builder means that it's the 'parent' element for a conditional element (see Using Conditional Fields for more info).
Inspecting the element properties, you can see first that this field is set to "Required." In order for the coupon code to work, form users cannot be allowed to skip this question!
In addition, in the "List Items" section, one of the radio buttons asking the question is set to be a 'currency' field, meaning it can impact the total dollar amount of the form submission. Specifically, a 'Yes' response carries with it a $5.00 discount.
So answering "Yes" to the question "Do you have a coupon code?" does two things: it reduces the overall cost of the form by $5, and it pops open a new, conditional element (called "Enter Code" in the form image above). Let's take a closer look at it.
In the "Validation" section of the "Enter Code" element, we see this:
The "Select Validation" section is set to "Advanced Validation." Then, the "Accepted Values" control is set to "By Phrase..." Doing this pops open the "Phrase" text box, into which we've typed the magic word, "coupon."
Next, we need to use the controls in this element to setup the conditional connection with the "Yes/No" radio buttons. Scroll down to the "Conditional Settings" Section.
Select the checkbox there. From the dropdown menu that appears, select the "Yes/No" radio button element that you created above. Finally, select the "Yes" checkbox. This will ensure that the coupon code entry field only appears (and the discount is only applied) when the user indicates that they have a coupon code to enter.
When the form is published, users will at first only see the yes/no radio buttons asking if they have a discount code. Selecting "Yes" will apply the $5 discount immediately, but will also require that the user enter the proper code (in this case, "coupon") - without the proper code, the validation will fail and the form cannot be submitted. If the user selects "No," then they don't get the $5 discount, and never see the coupon-entry element. The form can be submitted as normal.