Gravity Forms product calculations

Gravity Forms Product Calculations: The Complete Guide to Gravity Forms Pricing Fields

Written by Casey Burridge

Last updated:

Categories Gravity Forms, GravityMath

Are you looking for an easy way to do product calculations in Gravity Forms? Gravity Forms includes a number of features that allow it to function as an eCommerce solution. 

When selling products on your website, it’s helpful to be able to calculate shipping costs, discounts as well as other metrics such as average order value.

Product calculations are built into Gravity Forms but if you want to take things further you’ll need to install one or more plugins. In this post, we’ll show you different ways to perform Gravity Forms product calculations so that you can:

  • Create eCommerce reports
  • Update product prices based on conditional logic
  • Display the average order value
  • Calculate discount percentages
  • … and more!

Let’s get started! 🙌

When Should You Use Gravity Forms as an eCommerce Solution?

Although Gravity Forms is predominantly thought of as a form plugin, it can also be used as a WordPress eCommerce solution. Not only does Gravity Forms include a range of product pricing fields, but it also integrates with a wide variety of payment processors such as Stripe, PayPal, and more.

You should think about using Gravity Forms as your eCommerce solution if you have a small store that doesn’t require a lot of customization. While Gravity Forms works well for taking payments, it does not provide the expansive features offered by a dedicated eCommerce plugin like WooCommerce.

Product Field Calculations in Gravity Forms

Gravity Forms includes a range of Pricing fields that allow you to perform product calculations inside a form. To see the different fields available, open up the Pricing Fields tab from inside the form editor.

Gravity Forms Pricing fields

The following fields are available for displaying and calculating prices in Gravity Forms.

  • Product
    The Product field allows you to display products inside your form. The Product field supports several different Field Types, including Calculation, Single Product, Drop Down, Radio Buttons, and User Defined Price.
  • Quantity
    The Quantity field allows the user to specify a quantity of a certain product.
  • Option
    The Options field allows you to offer different options for a specific product with a cost attached.
  • Shipping
    The Shipping field allows you to add a shipping fee to the total cost of the order.
  • Total
    The Total field displays the order total. The Total field will dynamically update as the user selects different products, options, and shipping rates.

The above Pricing fields allow Gravity Forms to be used as a basic eCommerce solution. This is handy if you want to sell products on your website but don’t want the bloat of a full WooCommerce installation.

A form on the front end showing the product name, quantity, and shipping costs

Let’s have a look at some examples of how to perform different product calculations in Gravity Forms.

Example: Calculating a Percentage

Adding a Product field to your form and setting the Field Type to “Calculation” allows you to perform dynamic calculations inside your form. This is useful for several reasons. For example, you could calculate the product tax or VAT as a percentage of the total cost.

In this example, we’ve got a product that costs $20 with a product cost field that calculates the total product cost based on the quantity. Below that is a product calculation field called “Tax” that calculates 10% of the total product cost. Finally, there’s another calculation field that sums the two numbers together to get the total amount.

A product calculation form showing the product cost, tax and total amount

To add a calculation to your form, add a Product field and set the Field Type to Calculation

The Field Type dropdown menu set to 'Calculation'

Next, write your calculation using Gravity Forms merge tags inside the formula text box.

If you’re looking for a way to do more complex calculations in Gravity Forms, you’ll need to make use of one or more plugins.

Gravity Forms Product Calculation Plugins

There are several plugins that allow you to perform advanced calculations in Gravity Forms. Choosing the right plugin for you depends on your needs. Before we look at some more detailed examples, here is a brief overview of some different plugins that you can use for Gravity Forms Product calculations.

  • Math by GravityView
    This powerful add-on for Gravity Forms allows you to perform advanced calculations on your form data using the [gv_math] shortcode. Using [gv_math] you can create detailed reports, display the average order value, build frontend calculators, and more.
  • Gravity Forms eCommerce Fields
    This plugin adds support for a variety of eCommerce-related fields and features. If you’re looking to make Gravity Forms more eCommerce-friendly, Gravity Forms eCommerce Fields is the perfect add-on for you. 
  • Gravity Forms Conditional Pricing
    This add-on by Gravity Wiz allows you to create product pricing tiers based on conditional logic.

Now that we’ve gone over some of the helpful plugins for Gravity Forms product calculations, let’s have a look at some more specific examples with regards to eCommerce functionality in Gravity Forms.

Displaying the Average Order Value

When running an eCommerce store, there are several important metrics to keep track of. One of these is the average order value (AOV). Tracking the average order value over a certain period of time can help you understand your customers’ purchasing behavior

Using Math by GravityView, it’s easy to calculate the average order value. First, ensure your product order form contains a Total field. Next, add the below shortcode anywhere on your website to display the average order value (being sure to replace the form id and the merge tag).

$[gv_math id="22" scope="form"] {Total Amount:14:avg} [/gv_math]

As you can see, the shortcode contains two important parameters – ‘id’ and ‘scope’.

  • id – The ID of your form in Gravity Forms.
  • scope – This should be set to “form” as the calculation is being made using form entry data.

Finally, we’re calculating the average order value by using the Total merge tag with the :avg operator. When loading the page/post on the front end, the shortcode will be replaced with the average order value.

Average order value: $106

You can use the [gv_math] shortcode to calculate totals, averages, maximum values, minimum values, and much more!

Now let’s have a look at how to create detailed eCommerce reports.

Calculating Total Revenue

Calculating total revenue is a matter of adding up the total order amount for each order that you’ve received. This is easy to do using the [gv_math] shortcode

Once again, we’ll set the scope to “form” and then we’ll use the “Total Amount” merge tag with the :sum operator. This tells [gv_math] to add up all the values in the “Total Amount” field across all of our orders.

Total Revenue followed by a gv_math shortcode

As you can see, when we load the page on the front end, the shortcode is replaced by the total revenue amount.

Total Revenue: $6286

Next, we’ll look at using the filter parameter to calculate metrics based on certain conditions.

Calculating the Average Order Value for a Specific Date

The [gv_math] shortcode also accepts a filter parameter, allowing you to restrict calculations to certain entries based on conditions that you set. For example, by filtering on the order date, you could calculate the average order value for a single day.

[gv_math scope="form" id="22" filter="filter_13=2021-10-20"] {Total Amount:14:avg} [/gv_math]
The average order value on 10/20/21 was $148

Now let’s look at how to create eCommerce reports.

Creating eCommerce Order Reports

Math by GravityView integrates with GravityView allowing you to perform calculations inside a View. A View is a WordPress custom post type for displaying data from Gravity Forms.

By using the [gv_math] shortcode inside a View, you can perform calculations related to product pricing fields and create comprehensive eCommerce reports. In the below example, we’re using the GravityView DataTables layout and we’ve added a calculated column to display the total dollar amount owed based on the quantity of candy purchased.

A table showing different products that a person has bought with the amount owed displayed in the final column

Creating Different Pricing Tiers Using Conditional Logic

Conditional logic enables you to vary your product pricing based on the quantity purchased. For example, let’s say you’re selling custom-made t-shirts. If the user buys one it will cost them $20 but if they decide to buy 5, the price for one t-shirt drops to $15 each, saving them 25%.

To get started with conditional pricing, install Gravity Perks. After that, hover over Forms and click on Perks. Now scroll down to the Conditional Pricing perk and click Install. After activating conditional pricing, head over to your Form Settings and click on the Conditional Pricing tab on the left.

Now you can create unlimited pricing tiers based on conditional logic. When you’re done, make sure to click Save Conditional Pricing.

Conditional pricing

After loading our form on the front end and adding 3 custom t-shirts to our cart, you can see the price remains $20 each.

$20 for three t-shirts

However, as you can see, when we up the quantity to 5, the price drops to $15 per t-shirt!

$15 for five t-shirts

Now let’s look at what can be accomplished using another Gravity Wiz perk called “eCommerce Fields”.

Adding Additional Functionality With eCommerce Fields

The eCommerce Fields Perk offered by Gravity Wiz adds a bunch of helpful eCommerce features to Gravity Forms including the Tax, Discount, and Subtotal fields.

To get started with the eCommerce Fields add-on, hover over Forms in your WordPress Admin menu and click on Perks. Now scroll down to GP eCommerce Fields and click Install.

An arro pointing to the 'Install Perk' button under GP eCommerce Fields

After installing the GP eCommerce Fields perk, head back to your form and open up the Pricing Fields tab. You’ll see three new fields:

  • Subtotal
    This field allows you to show a subtotal before shipping or taxes have been applied. This makes it easier for customers to understand their orders.
  • Tax
    The Tax field allows you to calculate and apply a percentage-based tax to customer orders.
  • Discount
    This field allows you to add a flat rate or percentage discount to one or more products.
Gravity Forms Pricing fields

In this example, we’ve got a product that we’re selling for $50 but we’re giving the user a 10% discount. As they’ve ordered two of our products, this works out to be $10 off the order total.

An arrow pointing to a $10 discount on a form showing a product quantity and a total amount

That’s it! You should now have a good grasp of Gravity Forms product calculations and how to create different pricing structures in Gravity Forms 😎

Gravity Forms Product Calculations: Final Thoughts

Gravity Forms is the most powerful form plugin for WordPress, but it’s also a robust eCommerce tool. Gravity Forms includes several product fields and payment integrations, allowing you to sell products without any hassle 🛒

When running an eCommerce store, it’s important to be able to calculate freight or courier costs, discounts, and tax/VAT. In this post, we showed you several ways to perform product calculations in Gravity Forms. If you enjoyed this post, subscribe to our email list below or learn more about Gravity Forms calculations.

Join Our Newsletter!📧🙌

✅ Helpful Gravity Forms content straight to your inbox

✅ Be the first to hear about new updates and releases