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.

Comments

  1. revo
    revo February 18, 2024 at 6:22 am

    greeting is there any possiblity to add dynamic populated multiple product checkboxes with their corresponding quantity in gravity forms? So each product has its own quantity. Regards

    Reply
  2. Damian
    Damian December 30, 2022 at 12:52 am

    Is there a way to make the minimum apply only if a number has been entered?

    e.g. Allow the form to be submitted if the linked quantity field has been left empty or has a zero entered.

    Reply
    1. David Smith
      David Smith Staff January 2, 2023 at 12:05 pm

      If the field is empty, the minimum is ignored. We don’t have a ready solution for also allowing zero to bypass the minimum but we do provide minor customizations like this for our Pro customers if you’re interested. 🙂

  3. Mike
    Mike July 28, 2022 at 6:23 pm

    Is there anyway to set a “maximum” quantity, so that if you are only offering “4” of a specific type of product… once the form is submitted 4 times, it will automatically be removed from the options? Thanks!

    Reply
  4. Chris Rippe
    Chris Rippe January 20, 2022 at 8:19 pm

    I tried this but my format show us very clunky. Please see my test form. How do I get mine to look less clunky like yours?

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff January 21, 2022 at 6:21 am

      Hi Chris,

      I’m not really tracking your question very well. If you have an active Gravity Perks license, you can send us a message via our support forms with an export of your form so we can take a closer look at your setup.

      Best,

Leave a Reply

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

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.