Adding a coupon code field to your form is useful if you want to allow users to enter a coupon code that automatically deducts the discount amount from the Total amount. Follow the directions below to use Lookup fields to accomplish this.
Step 1: Create a form to add coupon code
This guide will help you create and use a form to manage your coupon codes and their corresponding discount amounts.
- Create a form called the Coupon Code List form that allows you to enter and store information about each discount offer.
- Add a Text field labeled Coupon Code.
- Add a Number field labeled Discount Amount.
- Enter a separate entry for each coupon code and its discount amount. For example, to create a 10% discount for Black Friday, enter
BlackFriday2016
in the Coupon Code field and
.10
in the Discount Amount field.
- Once you submit the form, the entries will appear on the form Entries page.
Note: Be sure to submit a form entry for each coupon code, as this will provide users with the data they need to find available discounts. - Create a new form or edit an existing form where users will enter the coupon codes and purchase an item.
- Add a Lookup → Single Line Text field and label the field Coupon code.
Set it up to search values from the Coupon Code List → Coupon Code field.
- Add a Number field to the form and label it Discount Amount. Select the Read only checkbox to prevent users from changing the discount amount.
In the field options, select Default Value and click the search icon to get the Lookup default value settings. Set it up to get values from the Coupon Code List → Discount Amount field and watch the Coupon Code Lookup field.
- Add a Number field and label it Total. Select Default Value (Calculation) and click the calculator icon. Your calculation will include something like:
[x]-([x]*[y])
Replace x with the ID of the field that determines the amount due and replace y with the ID of the Discount Amount field.If the amount is not included in a field, replace [x] with the amount. For example, if the regular price is $100, use 100-(100*[225]). Replace 225 with the ID of the Discount Amount field.
Step 2: Create a form to enter coupon code
That's it! When a user enters a valid coupon code, the Total amount will automatically be discounted. If it is not a valid coupon code, the Total amount will remain the same.