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! 🙌

## Table of contents

- When Should You Use Gravity Forms as an eCommerce Solution?
- Product Field Calculations in Gravity Forms
- Gravity Forms Product Calculation Plugins
- Displaying the Average Order Value
- Calculating Total Revenue
- Calculating the Average Order Value for a Specific Date
- Creating eCommerce Order Reports
- Creating Different Pricing Tiers Using Conditional Logic
- Adding Additional Functionality With eCommerce Fields
- Gravity Forms Product Calculations: Final Thoughts

## 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.

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.

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.

To add a calculation to your form, add a *Product *field and set the Field Type 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.

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.

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

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]`

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.

## 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.*

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.

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

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*.

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.

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.

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.