Tools
The ATUM tools API allows you to view and run tools.
The tools endpoints require the ATUM manage_settings capability. Some ATUM add-ons register their own tools on these endpoints (for example, Product Levels adds the sync_calculated_stock tool).
Tool properties
| Attribute | Type | Description |
|---|---|---|
id | string | A unique identifier for the tool. read-only |
name | string | Tool nice name. read-only |
description | string | Tool description. read-only |
config | object | If the tool needs config in order to work. Only returned when running a tool that received a config. |
success | boolean | Did the tool run successfully? Only returned when running a tool. read-only |
message | string | Tool return message. Only returned when running a tool. read-only |
result | object | Data returned by the tool, in case there were. Only returned when running a tool that returns extra data. read-only |
Available tools
| ID | Description |
|---|---|
enable-manage-stock | Enable the WooCommerce's manage stock at product level for all the products at once. |
disable-manage-stock | Disable the WooCommerce's manage stock at product level for all the products at once. |
enable-atum-control | Enable the ATUM's stock control option for all the products at once. |
disable-atum-control | Disable the ATUM's stock control option for all the products at once. |
clear-out-stock-threshold | Clear all previously saved Out of Stock Threshold values. |
sync_calculated_stock | Sync all the associated BOM products' stock with their current calculated stock. Only available when the BOM stock control is enabled in the Product Levels settings (or when recalculating the calculated stock without BOM stock control is allowed through a filter, in which case it only recalculates the calculated stock, without changing the WooCommerce stock). See its config options. Product Levels |
Retrieve a tool
This API lets you retrieve and view a specific tool by ID.
HTTP request
/wp-json/wc/v3/atum/tools/<id>curl https://example.com/wp-json/wc/v3/atum/tools/enable-atum-control \
-u consumer_key:consumer_secret{
"id": "enable-atum-control",
"name": "Enable ATUM Stock Control",
"description": "Enable the ATUM's stock control option for all the products at once.",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/enable-atum-control"
}
]
}
}List all tools
This API helps you to view all the available ATUM tools.
HTTP request
/wp-json/wc/v3/atum/toolscurl https://example.com/wp-json/wc/v3/atum/tools \
-u consumer_key:consumer_secret[
{
"id": "enable-manage-stock",
"name": "Enable WC's Manage Stock",
"description": "Enable the WooCommerce's manage stock at product level for all the products at once.",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/enable-manage-stock"
}
]
}
},
{
"id": "disable-manage-stock",
"name": "Disable WC's Manage Stock",
"description": "Disable the WooCommerce's manage stock at product level for all the products at once.",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/disable-manage-stock"
}
]
}
},
{
"id": "enable-atum-control",
"name": "Enable ATUM Stock Control",
"description": "Enable the ATUM's stock control option for all the products at once.",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/enable-atum-control"
}
]
}
},
{
"id": "disable-atum-control",
"name": "Disable ATUM Stock Control",
"description": "Disable the ATUM's stock control option for all the products at once.",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/disable-atum-control"
}
]
}
},
{
"id": "clear-out-stock-threshold",
"name": "Clear Out of Stock Threshold",
"description": "Clear all previously saved Out of Stock Threshold values.",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/clear-out-stock-threshold"
}
]
}
},
{
"id": "sync_calculated_stock",
"name": "Sync WooCommerce stock with calculated stock",
"description": "Sync all the associated BOM products' stock with their current calculated stock.",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/sync_calculated_stock"
}
]
}
}
]Run a tool
This API lets you run an ATUM tool. The POST and PATCH methods can be used too. Some tools accept a config object with extra options to run them.
If the ATUM Action Logs add-on is installed, every tool run through the API is recorded in the action logs.
HTTP request
/wp-json/wc/v3/atum/tools/<id>curl -X PUT https://example.com/wp-json/wc/v3/atum/tools/enable-manage-stock \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json"{
"id": "enable-manage-stock",
"name": "Enable WC's Manage Stock",
"description": "Enable the WooCommerce's manage stock at product level for all the products at once.",
"success": true,
"message": "All your products were updated successfully",
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/enable-manage-stock"
}
]
}
}Config options for sync_calculated_stock
Product Levels
By default, the sync_calculated_stock tool processes all the BOM products in a single request. To process them in batches, pass a config object with these options and run the tool again, increasing the offset, until result.finished is true:
| Parameter | Type | Description |
|---|---|---|
step | integer | Number of BOM products to process in this request. When it's set, the response includes a result object. |
offset | integer | Number of BOM products to skip. Default is 0. |
delete_transients | boolean | Whether to delete the ATUM transients after processing the products. |
The result object contains the total number of BOM products to process, whether the process is finished and the limit (the number of products already processed).
curl -X PUT https://example.com/wp-json/wc/v3/atum/tools/sync_calculated_stock \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"config": {
"step": 100,
"offset": 0,
"delete_transients": true
}
}'{
"id": "sync_calculated_stock",
"name": "Sync WooCommerce stock with calculated stock",
"description": "Sync all the associated BOM products' stock with their current calculated stock.",
"config": {
"step": 100,
"offset": 0,
"delete_transients": true
},
"success": true,
"message": "Stock updated successfully.",
"result": {
"total": 248,
"finished": false,
"limit": 100
},
"_links": {
"item": [
{
"embeddable": true,
"href": "https://example.com/wp-json/wc/v3/atum/tools/sync_calculated_stock"
}
]
}
}