Min/Max Quantities REST API reference

Use the WooCommerce REST API to read and update product and variation quantity rules added by Min/Max Quantities.

Note:

This is a Developer level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customizations. We are unable to provide support for customizations under our Support Policy.

Replace the example store URL, product IDs, and API credentials with your own. Use HTTPS and a REST API key with read and write permissions. See the REST API authentication guide.

REST API

↑ Back to top

These examples use the WooCommerce REST API v3 endpoints.

Min/Max Quantities extends the /products/ and /variations/ endpoint responses with new properties related to quantity rules.

Products

↑ Back to top

Product properties

  • group_of_quantity — integer; read write. Require products to be purchased in multiples of this value.
  • min_quantity — integer; read write. Minimum required product quantity.
  • max_quantity — integer string; read write. Maximum allowed product quantity.
  • exclude_order_quantity_value_rules — string; read write. Exclude product from order quantity and value rules.
  • exclude_category_quantity_rules — string; read write. Exclude product from category quantity rules.
  • combine_variations — string; read write. Enable this option to combine the quantities of all purchased variations when checking quantity rules. Note: Available only for Variable Products.

Example: Update quantity rules for a Simple product

curl -X PUT https://example.com/wp-json/wc/v3/products/12 \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
        "group_of_quantity": 2,
        "min_quantity": 4,
        "max_quantity": 8,
        "exclude_order_quantity_value_rules": "no",
        "exclude_category_quantity_rules": "yes"
}'

Replace 12 with the simple product ID.

Example: Update quantity rules for a Variable product

curl -X PUT https://example.com/wp-json/wc/v3/products/14 \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
        "group_of_quantity": 2,
        "min_quantity": 4,
        "max_quantity": "",
        "exclude_order_quantity_value_rules": "no",
        "exclude_category_quantity_rules": "yes",
        "combine_variations": "no"
}'

Replace 14 with the variable product ID.

Error codes

When updating quantity rules for a product, here are some errors that you might get in the response:

  • woocommerce_rest_invalid_product_type_allow_combinations — This error is triggered when trying to set the combine_variations key on a product that is not a Variable product.
  • woocommerce_rest_invalid_min_quantity — This error is triggered when trying to set a min_quantity that is either greater than the Max Quantity or not a multiple of the Group of value.
  • woocommerce_rest_invalid_max_quantity — This error is triggered when trying to set a max_quantity that is not a multiple of the Group of value.

Variations

↑ Back to top

Variation properties

  • variation_quantity_rules — string; read write. Enable this option to set quantity rules for a specific variation.
  • group_of_quantity — integer; read write. Require products to be purchased in multiples of this value.
  • min_quantity — integer; read write. Minimum required product quantity.
  • max_quantity — integer string; read write. Maximum allowed product quantity.
  • exclude_order_quantity_value_rules — string; read write. Exclude product from order quantity and value rules.
  • exclude_category_quantity_rules — string; read write. Exclude product from category quantity rules.

Example: Update quantity rules for a variation

curl -X PUT https://example.com/wp-json/wc/v3/products/14/variations/15 \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
        "variation_quantity_rules": "yes",
        "group_of_quantity": 3,
        "min_quantity": 3,
        "max_quantity": 12,
        "exclude_order_quantity_value_rules": "no",
        "exclude_category_quantity_rules": "yes"
}'

Replace 14 with the variable product ID and 15 with the variation ID.

Error codes

When updating quantity rules for a variation, here are some errors that you might get in the response:

  • woocommerce_rest_invalid_product_type_allow_combinations — This error is triggered when trying to set the combine_variations key on a variation. This key can only be set on Variable products.
  • woocommerce_rest_invalid_variation_min_quantity — This error is triggered when trying to set a min_quantity that is either greater than the Max Quantity or not a multiple of the ‘Group of’ value.
  • woocommerce_rest_invalid_variation_max_quantity — This error is triggered when trying to set a max_quantity that is not a multiple of the Group of value.

For setting up rules in the dashboard, see Min/Max Quantities.

Questions and support

↑ Back to top

Something missing from this documentation? Still have questions and need assistance?

  • If you have a question about a specific extension or theme you’d like to purchase, contact us to get answers.
  • If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.

Related Products

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Offer add-ons like gift wrapping, special messages or other special options for your products.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.