Starting with Version 1.3 of our WooCommerce Multi Inventory Plugin we offer a built in REST API functionality. This allows vendors or other customers to fetch multi inventory stocks, locations and more.
REST API Base
The Base for all multi inventory calls of our API is “/wc/multi-inventory/v1/”. A full call would include also your site URL and wp-json of course.
This is an example full base:
https://www.YOURDOMAIN.COM/wp-json/wc/multi-inventory/v1/inventories?consumer_key=YOUR_KEY&consumer_secret=YOUR_KEY
Get Inventories
The first REST API Call is to get all inventory locations.
/wp-json/wc/multi-inventory/v1/inventories
Get Product Inventory Stocks
To get the inventory stock data for a product you can use the stock call. Parameters for the call are: sku or product_id. Example:
/wp-json/wc/multi-inventory/v1/stock?sku=123
Parameters:
sku OR product_id
Update Product Inventory Stocks
To update a product with inventory stock information use the stock call as POST.
/wp-json/wc/multi-inventory/v1/stock?stock=5&sku=123&inventory=71
Parameters:
stock
sku OR product_id inventory (inventory id)
Get Inventory Orders
If you need all orders by inventory ID, use the orders call. Parameter is inventory (containing your inventory ID).
/wp-json/wc/multi-inventory/v1/orders?inventory=71
Hi, I noticed that the first variable should be stock rather than inventory. Also this needs to be secured so that it is not abused.
/wp-json/wc/multi-inventory/v1/stock?stock=5&sku=123&inventory=71
Thanks for the information. We corrected the REST API FAQ now. For security, all requests require a REST API Authorization via consumer secret.
Hi, they could add images or information for GET OR POST requests whether they are successful or not.
Hi, what about prices? Can be change with the API?
Well currently we only support stock updates via API, but we can customize / add this feature for you on Charge. Contact us at su*****@we******.io
Can you please provide a update for this.. As the Price as per inventory feature is there in plugin and it should be availbale in restapi as well.
Hi,
Is there a way to update the stock quantity for multiple inventories with a single call? That functionality would be great.
Thanks!
the inventory ID is the TAG_ID of the taxonomy?
Yes correct. You can get the term id (tag id) when you edit an inventory in the backend and then take a look in the URL.
I am placing a woocommerce order via Rest api, however I am unable to set the inventory while placing the order due to which on Order >> My order >> Products Ordered >> Inventory dropdown is not set.
Is there an api using which I can set the inventory for the order ? and also reduce the stock for the same ?
Thanks for the great work with this plugin! I did notice however, that when I am interacting with the REST API locally (ie. via rest_do_request() rather than wp_remote_get()), the entire execution of the script stops abruptly after echoing out the JSON. This is fine I guess for HTTP REST API requests, but it breaks execution completely when using rest_do_request().
Looking in the classes/class-woocommerce-multi-inventory-rest-controller.php file, I can see that all the $response returns are just die(json_encode($response)), which is the culprit here and stops all execution. It would be nice if this was updated to return the data gracefully, for example by using return rest_ensure_response($response) instead. I’ve tried this with my local copy of the plugin (with version 1.5.4) and it works great for both HTTP REST API requests and via rest_do_request(). Could you please consider updating your plugin to behave this way?
Thanks for your suggestions. Please send me your code changes to su*****@we******.io and I will review them internally.