In this example, you will learn how to create a discount code to be used with Caldera Forms and PayPal Express add-on to offer users $10 off their orders.
If you do not know how to implement PayPal Express with Caldera Forms, have a look at ourĀ Getting Started Guide.
Creating A Calculation Form With A Discount Code
1. Login to your WordPress dashboard and navigate to Caldera Forms editor and selecting your Caldera Form and selecting edit for the form you would like to allow the discount code functionality to.
2. Once in the Caldera Form editor, create a hidden field that will be used to match your discount code. Set the field’s default value to the discount code you would like to match (i.e. CALDERA10) – please note that the discount code is case sensitive.
3. Create another hidden field that will contain the discount code’s amount, in our case we will offer $10 off the total price if the code matches. Set the default value to 10 and name this field accordingly.
4. Inside your calculation field, subtract the field created in step 3 from the total. (i.e. %total% – %discount_code_val% )
5. Navigate over to Conditions tab, found at the top of the page and add a new conditional group. (This is where we will see if our users discount code matches that of the field we created in step 2). The reason we do it this way and don’t set the discount code inside the condition itself is for future uses, you are able to easily adjust the code within the form editor.
6. Set the condition to ‘show‘ the hidden field we created in step 3 if the field in step 2 matches CALDERA10. Your condition will have the following logic – if field 2 is equal to CALDERA10 show hidden field in step 3. This will then include the discount code value ($10) in the calculation field.
7. Save your form.
This will use the discounted amount when using PayPal Express or any other payment gateway with your Caldera Forms. If a user does not enter a discount code, the full amount will be charged.
Go Forth And Prosper
Now that you’ve learnt to implement a simple discount code feature with Caldera Forms. You are able to make more sales and offer multiple discounts options. You may also use some of the logic to automatically apply a discount depending on user selection with the use of dropdowns or radioboxes.