productivity
WooCommerce Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the WooCommerce KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.woocommerce.*.
Use lua_read_doc("integrations.woocommerce") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
WooCommerce workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.woocommerce.list_products({per_page = 1, page = 1, search = "example_search", status = "example_status", category = "example_category", sku = "example_sku", orderby = "example_orderby", order = "example_order"}))' --json kosmo integrations:lua --eval 'print(docs.read("woocommerce"))' --json
kosmo integrations:lua --eval 'print(docs.read("woocommerce.list_products"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local woocommerce = app.integrations.woocommerce
local result = woocommerce.list_products({per_page = 1, page = 1, search = "example_search", status = "example_status", category = "example_category", sku = "example_sku", orderby = "example_orderby", order = "example_order"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.woocommerce, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.woocommerce.default.* or app.integrations.woocommerce.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need WooCommerce, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
WooCommerce — Lua API Reference
list_products
List products from the WooCommerce catalog with filtering and pagination.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of products per page (default: 10, max: 100) |
page | integer | no | Page number for pagination (default: 1) |
search | string | no | Search products by name or description |
status | string | no | Filter by status: “publish”, “draft”, “pending”, “private”, “trash” |
category | string | no | Filter by category ID |
sku | string | no | Filter by SKU |
orderby | string | no | Sort field (“date”, “id”, “title”, “slug”, “price”) |
order | string | no | Sort direction: “asc” or “desc” |
Example
local result = app.integrations.woocommerce.list_products({
per_page = 10,
orderby = "price",
order = "desc"
})
for _, product in ipairs(result) do
print(product.name .. " - $" .. product.regular_price)
end
get_product
Get a single product by ID with full details.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The product ID |
Example
local product = app.integrations.woocommerce.get_product({
id = 123
})
print(product.name)
print("Price: $" .. product.regular_price)
print("SKU: " .. (product.sku or "N/A"))
create_product
Create a new product in the WooCommerce catalog.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Product name |
regular_price | string | yes | Base price (e.g., “29.99”) |
type | string | no | Product type: “simple”, “grouped”, “external”, “variable” (default: “simple”) |
sku | string | no | Unique SKU |
description | string | no | Product description (HTML allowed) |
short_description | string | no | Short description |
weight | string | no | Product weight |
categories | array | no | Array of {id} objects |
manage_stock | boolean | no | Enable stock management |
stock_quantity | integer | no | Stock level |
status | string | no | ”publish”, “draft”, “pending”, “private” |
images | array | no | Array of {src} objects |
Example
local product = app.integrations.woocommerce.create_product({
name = "Premium Widget",
regular_price = "49.99",
type = "simple",
sku = "WDG-PREM-001",
weight = "0.75",
categories = {{id = 1}, {id = 5}},
manage_stock = true,
stock_quantity = 100,
description = "<p>A premium quality widget.</p>"
})
print("Created product ID: " .. product.id)
list_orders
List orders with filtering and pagination.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Orders per page (default: 10, max: 100) |
page | integer | no | Page number (default: 1) |
status | string | no | Filter by status: “pending”, “processing”, “on-hold”, “completed”, “cancelled”, “refunded”, “failed” |
customer | integer | no | Filter by customer ID |
after | string | no | Orders created after this date (ISO 8601) |
before | string | no | Orders created before this date (ISO 8601) |
orderby | string | no | Sort field |
order | string | no | Sort direction: “asc” or “desc” |
Example
local orders = app.integrations.woocommerce.list_orders({
status = "completed",
per_page = 10,
orderby = "date",
order = "desc"
})
for _, order in ipairs(orders) do
print("Order #" .. order.id .. " - $" .. order.total)
end
get_order
Get a single order by ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The order ID |
Example
local order = app.integrations.woocommerce.get_order({
id = 456
})
print("Order #" .. order.id)
print("Status: " .. order.status)
print("Total: $" .. order.total)
list_customers
List customers with filtering and pagination.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Customers per page (default: 10) |
page | integer | no | Page number (default: 1) |
search | string | no | Search by name or email |
orderby | string | no | Sort field |
order | string | no | Sort direction |
Example
local customers = app.integrations.woocommerce.list_customers({
per_page = 10,
orderby = "registered_date",
order = "desc"
})
for _, customer in ipairs(customers) do
print(customer.first_name .. " " .. customer.last_name .. " - " .. customer.email)
end
get_current_user
Get system status and verify the API connection.
Parameters
None.
Example
local status = app.integrations.woocommerce.get_current_user({})
print("Store: " .. (status.store_name or "N/A"))
Multi-Account Usage
If you have multiple WooCommerce stores configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.woocommerce.list_products({per_page = 10})
-- Explicit default (portable across setups)
app.integrations.woocommerce.default.list_products({per_page = 10})
-- Named accounts (e.g., different stores)
app.integrations.woocommerce.us_store.list_products({per_page = 10})
app.integrations.woocommerce.eu_store.list_products({per_page = 10})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# WooCommerce — Lua API Reference
## list_products
List products from the WooCommerce catalog with filtering and pagination.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of products per page (default: 10, max: 100) |
| `page` | integer | no | Page number for pagination (default: 1) |
| `search` | string | no | Search products by name or description |
| `status` | string | no | Filter by status: "publish", "draft", "pending", "private", "trash" |
| `category` | string | no | Filter by category ID |
| `sku` | string | no | Filter by SKU |
| `orderby` | string | no | Sort field ("date", "id", "title", "slug", "price") |
| `order` | string | no | Sort direction: "asc" or "desc" |
### Example
```lua
local result = app.integrations.woocommerce.list_products({
per_page = 10,
orderby = "price",
order = "desc"
})
for _, product in ipairs(result) do
print(product.name .. " - $" .. product.regular_price)
end
```
---
## get_product
Get a single product by ID with full details.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The product ID |
### Example
```lua
local product = app.integrations.woocommerce.get_product({
id = 123
})
print(product.name)
print("Price: $" .. product.regular_price)
print("SKU: " .. (product.sku or "N/A"))
```
---
## create_product
Create a new product in the WooCommerce catalog.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Product name |
| `regular_price` | string | yes | Base price (e.g., "29.99") |
| `type` | string | no | Product type: "simple", "grouped", "external", "variable" (default: "simple") |
| `sku` | string | no | Unique SKU |
| `description` | string | no | Product description (HTML allowed) |
| `short_description` | string | no | Short description |
| `weight` | string | no | Product weight |
| `categories` | array | no | Array of {id} objects |
| `manage_stock` | boolean | no | Enable stock management |
| `stock_quantity` | integer | no | Stock level |
| `status` | string | no | "publish", "draft", "pending", "private" |
| `images` | array | no | Array of {src} objects |
### Example
```lua
local product = app.integrations.woocommerce.create_product({
name = "Premium Widget",
regular_price = "49.99",
type = "simple",
sku = "WDG-PREM-001",
weight = "0.75",
categories = {{id = 1}, {id = 5}},
manage_stock = true,
stock_quantity = 100,
description = "<p>A premium quality widget.</p>"
})
print("Created product ID: " .. product.id)
```
---
## list_orders
List orders with filtering and pagination.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Orders per page (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |
| `status` | string | no | Filter by status: "pending", "processing", "on-hold", "completed", "cancelled", "refunded", "failed" |
| `customer` | integer | no | Filter by customer ID |
| `after` | string | no | Orders created after this date (ISO 8601) |
| `before` | string | no | Orders created before this date (ISO 8601) |
| `orderby` | string | no | Sort field |
| `order` | string | no | Sort direction: "asc" or "desc" |
### Example
```lua
local orders = app.integrations.woocommerce.list_orders({
status = "completed",
per_page = 10,
orderby = "date",
order = "desc"
})
for _, order in ipairs(orders) do
print("Order #" .. order.id .. " - $" .. order.total)
end
```
---
## get_order
Get a single order by ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The order ID |
### Example
```lua
local order = app.integrations.woocommerce.get_order({
id = 456
})
print("Order #" .. order.id)
print("Status: " .. order.status)
print("Total: $" .. order.total)
```
---
## list_customers
List customers with filtering and pagination.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Customers per page (default: 10) |
| `page` | integer | no | Page number (default: 1) |
| `search` | string | no | Search by name or email |
| `orderby` | string | no | Sort field |
| `order` | string | no | Sort direction |
### Example
```lua
local customers = app.integrations.woocommerce.list_customers({
per_page = 10,
orderby = "registered_date",
order = "desc"
})
for _, customer in ipairs(customers) do
print(customer.first_name .. " " .. customer.last_name .. " - " .. customer.email)
end
```
---
## get_current_user
Get system status and verify the API connection.
### Parameters
None.
### Example
```lua
local status = app.integrations.woocommerce.get_current_user({})
print("Store: " .. (status.store_name or "N/A"))
```
---
## Multi-Account Usage
If you have multiple WooCommerce stores configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.woocommerce.list_products({per_page = 10})
-- Explicit default (portable across setups)
app.integrations.woocommerce.default.list_products({per_page = 10})
-- Named accounts (e.g., different stores)
app.integrations.woocommerce.us_store.list_products({per_page = 10})
app.integrations.woocommerce.eu_store.list_products({per_page = 10})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.woocommerce.list_products({per_page = 1, page = 1, search = "example_search", status = "example_status", category = "example_category", sku = "example_sku", orderby = "example_orderby", order = "example_order"})
print(result) Functions
list_products Read
List products from the WooCommerce catalog. Supports pagination, filtering by name or SKU, and including variants/images.
- Lua path
app.integrations.woocommerce.list_products- Full name
woocommerce.woocommerce_list_products
| Parameter | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of products to return per page (default: 10, max: 100). |
page | integer | no | Page number for pagination (default: 1). |
search | string | no | Search products by name or description. |
status | string | no | Filter by product status: "publish", "draft", "pending", "private", or "trash". |
category | string | no | Filter by category ID. |
sku | string | no | Filter by SKU. |
orderby | string | no | Sort collection by field (e.g., "date", "id", "title", "slug", "price"). |
order | string | no | Sort direction: "asc" or "desc". |
get_product Read
Get a single product from the WooCommerce catalog by its ID. Returns full product details.
- Lua path
app.integrations.woocommerce.get_product- Full name
woocommerce.woocommerce_get_product
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The product ID. |
create_product Write
Create a new product in the WooCommerce catalog. Requires name and regular_price. Supports type (simple, grouped, external, variable), SKU, description, and more.
- Lua path
app.integrations.woocommerce.create_product- Full name
woocommerce.woocommerce_create_product
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Product name. |
regular_price | string | yes | Base price (e.g., "29.99"). |
type | string | no | Product type: "simple", "grouped", "external", or "variable" (default: "simple"). |
sku | string | no | Unique SKU for the product. |
description | string | no | Product description (HTML allowed). |
short_description | string | no | Short product description. |
weight | string | no | Weight of the product. |
categories | array | no | Array of category objects with "id" keys. |
manage_stock | boolean | no | Whether to enable stock management (default: false). |
stock_quantity | integer | no | Stock level (when manage_stock is true). |
status | string | no | Product status: "publish", "draft", "pending", or "private" (default: "publish"). |
images | array | no | Array of image objects with "src" key. |
list_orders Read
List orders from the WooCommerce store. Supports filtering by status, customer, and pagination.
- Lua path
app.integrations.woocommerce.list_orders- Full name
woocommerce.woocommerce_list_orders
| Parameter | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of orders per page (default: 10, max: 100). |
page | integer | no | Page number for pagination (default: 1). |
status | string | no | Filter by order status: "pending", "processing", "on-hold", "completed", "cancelled", "refunded", or "failed". |
customer | integer | no | Filter by customer ID. |
after | string | no | Limit response to orders created after this date (ISO 8601, e.g., "2025-01-01T00:00:00"). |
before | string | no | Limit response to orders created before this date (ISO 8601). |
orderby | string | no | Sort collection by field (e.g., "date", "id", "total"). |
order | string | no | Sort direction: "asc" or "desc". |
get_order Read
Get a single order from the WooCommerce store by its ID. Returns full order details including line items and totals.
- Lua path
app.integrations.woocommerce.get_order- Full name
woocommerce.woocommerce_get_order
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The order ID. |
list_customers Read
List customers from the WooCommerce store. Supports filtering by name or email and pagination.
- Lua path
app.integrations.woocommerce.list_customers- Full name
woocommerce.woocommerce_list_customers
| Parameter | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of customers per page (default: 10, max: 100). |
page | integer | no | Page number for pagination (default: 1). |
search | string | no | Search by customer name or email. |
orderby | string | no | Sort collection by field (e.g., "id", "name", "registered_date"). |
order | string | no | Sort direction: "asc" or "desc". |
get_current_user Read
Get the system status from WooCommerce. Use this to verify the API connection is working and retrieve store information.
- Lua path
app.integrations.woocommerce.get_current_user- Full name
woocommerce.woocommerce_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||