How to Setup Bulk Pricing with a Calculated Unit for Gravity Forms
Many products offer bulk pricing or some other conditional pricing structure. This can be used to encourage customers to purchase more of the product or to make the purchasing process easier on both owner and customer.
In this tutorial, we will combine the power of Gravity Forms with two of our Perks, GP Conditional Pricing and GP Copy Cat, to build a form that can conditionally calculate a price per unit based on the number of units being purchased.
Let’s get started!
- Create a Height Field
- Create a Width Field
- Create a Calculated Unit Field
- Create a Product Field
- Copy Calculated Unit to Product Quantity Field (with GP Copy Cat).
- Create Pricing Rules Based on Quantity (with GP Conditional Pricing).
1. Create a Height Field
Let’s add a Number field to the form where the user will input the desired height.
2. Create a Width Field
Add a second Number field to the form where the user will input the desired width.
3. Create a Calculated Unit Field
Add a third Number field. This will be a calculated number. This is achieved with two simple steps.
- Check the “Enable Calculation” option.
- Specify your formula using the “Insert Merge Tag” drop down. We are calculating square footage so we will multiply the height field by the width field.
Hiding the Calculated Unit
In many cases, you may want the calculated unit to determine the total price; however, you do not wish the calculated unit to be visible to the user. You can hide any field from view by adding the “gf_hidden” class to the Custom CSS Class field setting.
4. Create a Product Field
Add a Product field. The price of this field will be dynamically set via the pricing rules you will configure in Step 6. The label of the field does not impact the functionality. We’ve labeled our product “Material”. The more material that is ordered (based on our calculated unit) the lower the price.
5. Copy Calculated Unit to Product Quantity Field (with GP Copy Cat).
We want our calculated unit (i.e. the total square footage of material we are ordering) to be applied as the quantity of our Material product field. Gravity Forms doesn’t support calculated quantities by default. This is why we have our calculated unit as a separate calculated Number field.
With GP Copy Cat, we can copy the value of that Number field to the Quantity input of our Material product field.
- Install and activate GP Copy Cat.
- Open the Square Footage field settings.
- Select the “Appearance” tab.
- Enter the Copy Cat class to copy the value of the Square Footage field to the Material’s Quantity input. Based on our field IDs, the class would be:
The first number (
18) is the ID of the field we are copying from (Square Footage) and the second number (
20.3) is the input ID of the input we are copying to (quantity).
Learn more about using GP Copy Cat here.
Use GP Read Only to set Quantity as read only. This would prevent the user from modifying the Quantity manually.
6. Create Pricing Rules Based on Quantity (with GP Conditional Pricing).
Lastly, we will configure the conditional pricing rules for the form. Conditional Pricing will allow us to modify the price of the Material product based on how much Square Footage is being purchased.
- Install and activate GP Conditional Pricing.
- Select “Conditional Pricing” from the Form Settings menu.
- Select the Material product field from the “Select a Product” drop down.
- Create your first pricing rule.
- Click the “Add New Pricing Level” button to create additional pricing rules for this product.
Here is how we’ve configured our pricing rules for the demo.
What questions do you still have?
Do you still have any questions about how to get this setup? We’d love to know what they are. Let us know!