A user on the Gravity Forms Support Forums posted today asking if it were possible to setup a shipping fee that was only applicable if the order total was over a certain amount. As of Gravity Forms v1.6.4, this is now possible!
The form total (aka order total) may not be available for conditional logic; however, Number fields are and as of Gravity Forms v1.6.4, Number fields have been enhanced to support calculations. This tutorial will demonstrate how Gravity Form calculations work and how you can use this new feature to setup conditional shipping.
Calculated Form Total
I’m going to assume you already have your form setup with products, options, etc. The next step will be to add a Number field. Open up the settings for this field and click “Enable Calculation” to reveal the “Formula” textarea.
Now comes the tedious part.
In order to get the form total you will need to calculate each product’s total and then add them together. To get a product’s total, you must add the product price to the product options price and then multiply this sum by the product quantity. You then add up each product’s total to get the form total.
(Product Price + Option Price) * Product Quantity
(Product Price + Option #1 Price + Option #2 Price) * Product Quantity
((Product #1 Price + Option #1 Price) * Product #1 Quantity) + ((Product #2 Price + Option #2 Price) * Product #2 Quantity)
For simple forms this is no problem. For larger forms… have fun.
Shipping Conditional Logic
Now that you have your Number field setup as a calculation, you’re ready to configure your Shipping field’s conditional logic. For this example, we’ll configure the Shipping field to only display if the “Calculated Form Total” is greater than 10.
Hiding the Calculated Form Total
So you’ve tried it out and it’s amazing, but… you probably don’t want to leave your Calculated Form Total field visible for users to see. Just add “gf_hidden” as a CSS class for this field on the “Advanced” tab. Presto strango!
That’s a wrap! What do you think? Will you use this technique on your own forms?