How to Setup Bulk Pricing with a Calculated Unit for Gravity Forms
Calculate how much of a product is being ordered and dynamically set the unit price based on the calculated value. Useful for dimension-based calculations like square footage and volume.
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!
Steps
- 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:
copy-18-to-20.3
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!
This is looking pretty close to what we want, but would it work with Drop Down Products so that different materials can have different pricing conditions? Example:
Material 1: Price is $1.00 if quantity is less than 10 Price is $.90 if quantity is less than 20 Price is $.80 if quantity is less than 30 Price is $.75 if quantity is less than 40 Price is $.70 if quantity is 40 or more
Material 2 (premium material): Price is $1.50 if quantity is less than 10 Price is $1.40 if quantity is less than 20 Price is $1.30 if quantity is less than 30 Price is $1.20 if quantity is less than 40 Price is $1.00 if quantity is 40 or more
Hi Brian,
GP Conditional Pricing also works with Dropdown Products and it will work perfectly for your use case.
Best,
Thanks for your response. I’m looking at the demo on this particular tutorial and some of the functionality isn’t making sense to me. Why is the quantity box being auto filled? And why does it change as I change sizes?
What we are trying to accomplish Stickers, posters, etc -Enter width -Enter height -Select Material (different price for different materials with conditional pricing on each) -Select Quantity
Conditional pricing should be based on total square units. So whether they order 1,000 stickers at 2″ x 2″ each (4,000 sq inches) or 40 stickers at 10″ x 10″ each (4,000 sq inches) the price will be the same because it will fall into whatever pricing condition is set for 4,000 sq inches.
Hi Brian,
This tutorial is specific to a use case where the square foot of material is used as the quantity for the Product. The quantity field is being auto-filled because of the copy cat class that is used to copy the calculated square foot within the Number field into the Quantity field.
You’re free to set up your form in a different way, such that your users will manually enter the quantity and you will still be able to use the GP Conditional Pricing to determine the price of the product based on the quantity entered.
If you’re a Gravity Perks License holder, you can send us an export of the form via our support form so we can take a closer look at your form setup and further assist you.
Best,
GP Conditional Pricing is more completed if price can set by calculation not flat price.
Hi Mustaqim, I’ve responded to your email requested more details on how you envision this feature working.
I was able to solve this. Thanks a lot.
Hello,
I’m hoping to find a solution for this. It’s something similar to this setup. Here’s what I am looking to achieve.
I have a list field and a Yes/No Drop-down in the list field using this plugin: https://wordpress.org/plugins/gravity-forms-list-field-select-drop-down/
The list field will be used to add drivers and each driver will have a drop-down in the row to select from Yes/No
The Yes/No is basically an up-sell product.
So I need to find a way to calculate the number of “Yes” in the list field and copy that to the quantity field of the up-sell product (Maybe using your awesome GP copy-cat perk or maybe with dynamic population)
I’ve looked around a lot but haven’t found anything yet. Hope I was able explain myself.
Hi Brijesh, we don’t have a solution for this.
Is this something possible in GF at all?
If yes, can you let me know where to look at or guide me about custom code?
Thanks for your help!