Min/Max Quantities and REST API

Hey @vlasar

The Min/Max Quantities extension does not seem to introduce dedicated REST API fields — however, you can use the REST API to create/read/update product metadata like this:


"meta_data": [
    {
        "key": "test_meta1", 
        "value": "test_meta_val1"
    }
  ]

You can replace test_meta1 with any of the following meta keys:

minimum_allowed_quantity
maximum_allowed_quantity
group_of_quantity

When working with variations, you’d use:

variation_minimum_allowed_quantity
variation_maximum_allowed_quantity
variation_group_of_quantity

Let me know if this helps!

Cheers,
Manos

Thread Starter
vlasar

(@vlasar)

Hello @franticpsyx

Thank you for the quick response.

That works great!

I’m new to WooCommerce, so I didn’t realize those product properties might be introduced as “meta_data”. Do all extensions introduce new product properties through “meta_data”? I assume some do this through product attributes? I’m asking since we have a few more plugins that introduce product properties that we might need to be able to set through the REST API.

Glad I was able to assist!

> Do all extensions introduce new product properties through “meta_data”? I assume some do this through product attributes?

Some extensions with a REST API integration extend the REST API scheme with their own fields/attributes. Product Bundles [is a good example]). Generally speaking, if an extension provides its own REST API attributes, you can expect those to be documented in its WooCommerce.com documentation.

Otherwise, you can use the REST API meta_data field only to the extend that the feature you wish to customize/extend via the REST API stores its data as post meta. Some extensions, for example, may use their own custom tables to store information. There is no straightforward way to understand this — your best bet is to scan the extension code in order to understand how it stores its data.

Does this help?

Cheers
Manos

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer