1. Home
  2. WooCommerce MultiLocation & Order Routing
  3. Developer Docs
  4. Using API or CSV import/export to manage product/variation inventory

Using API or CSV import/export to manage product/variation inventory

By default, inventory can be added/updated for each location when editing a product or variation manually in the WooCommerce admin. Once the inventory is set, and the product is saved, we will recalculate the total inventory for the product/variation to be the sum of the inventory in all locations.

However, we are also compatible with retrieving and updating inventory levels over both the WooCommerce REST API and any CSV import/export tool that recognizes custom fields, including the built-in WooCommerce import/export field.

  • Inventory is always stored/managed using the location ID. This is set when creating a location, in the Locations tab of our integration. The Location ID is used both in the custom fields in the database and over the WooCommerce REST API.
  • Inventory levels are stored with each product in custom/meta fields. These fields would be accessible through any CSV import/export tool that supports meta fields – including the built-in WooCommerce import/export tool. The format of these custom field names are _stocks_location_locationid

Handling inventory using CSV import/export tools

We support retrieving and updating inventory levels via any CSV import/export plugin that supports custom/meta fields, as noted above. Simply ensure these custom fields have their own column in the import file, and they will correctly update location inventory as noted above.

Handling inventory using WooCommerce REST API

We support retrieving and updating inventory levels via the WooCommerce REST API, also using the Location ID. When sending a GET request for the products endpoint, the response will contain a new property called warehouse – that will contain a list of location IDs and inventory value in that location. An example of a response is listed below. The structure is: “locationid”: “inventorylevel”

"warehouse": {
            "5": "1",
            "43": "0",
            "44": "2"

When sending a PUT request to update product inventory, the same structure as above should be used to easily update the inventory by location.

Updated on April 30, 2019

Was this article helpful?