How To Set a Min/Max Quantity on Single Product Fields in Gravity Forms

Have you ever needed to set a minimum or maximum quantity for Product fields in Gravity Forms? If you’re selling a product that requires a minimum order or you want to limit the quantity for a single order, this tutorial is for you.

Getting Started

Setting a min/max range is simple with Number fields, however Product fields don’t support it. Fortunately, Quantity fields behave just like any other Number field, so you can set a min/max range on them.

Steps

  1. Add a Quantity Field
  2. Map Quantity Field and set Min/Max
  3. Disable Quantity in Product Field

Step 1 – Add a Quantity Field

Start by adding a separate Quantity field to the form.

Step 2 – Map Quantity Field and set Min/Max

Map the separate Quantity field to your existing Product field. You can then set a min/max range on the Quantity field.

Step 3 – Disable Quantity in Product Field

With a separate Quantity field in place, disable the Quantity field within the Product itself. Otherwise, you’ll end up with two Quantity fields on the form.

That’s It!

With the Min/Max in place on the Quantity field, users will be limited to the range you have set. If the form is submitted with a number outside of that range, they’ll see a validation error on submission.

Taking it Further

Rounding by Increments

Our Rounding by Increments snippet can automatically enforce min/max ranges and it will let you set the range on a Product field without the need for a separate Quantity field. Simply add the gw-round-min-n and gw-round-max-n classes to the Appearance tab for the Product field and the snippet will handle enforcement.

With the classes in place, the snippet will replace any value outside of the range with the next valid value.

Quantity Based Pricing

Pair this technique with GF Conditional Pricing to set up quantity based pricing and charge different amounts based on the number of products your customers order.

For example, say you have a shop that sells face masks in bulk to businesses. You could require a minimum order of 10 masks and also offer a discount if the order quantity is higher than 40. Check out our article on How to Setup Bulk Pricing with Gravity Forms for more info.

Leave a Comment

Your email address will not be published. Required fields are marked *