Create WooCommerce Product Variation
woocommerce_create_product_variationCreate a new variation for an existing variable product by specifying attribute combinations like size and color, along with optional pricing and stock details.
Instructions
Create a new variation for an existing variable product. The parent product must already have variation-enabled attributes defined (e.g. Size, Color).
Args:
product_id (number, required): parent variable product ID
attributes (array, required): [{name, option}] matching the parent's variation attributes
sku, regular_price, sale_price, manage_stock, stock_quantity, stock_status (optional)
response_format ('markdown'|'json'): default 'markdown'
Returns: The newly created variation object.
Examples:
Use when: "add a Large/Blue variation at $30" -> attributes=[{name:"Size",option:"Large"},{name:"Color",option:"Blue"}], regular_price="30.00"
Error Handling:
Returns "Error: Bad request (400)" if the attribute name/option doesn't match the parent product's defined attributes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sku | No | ||
| attributes | Yes | The attribute/option combination that defines this variation | |
| product_id | Yes | The parent variable product's numeric ID | |
| sale_price | No | Sale price as numeric string | |
| manage_stock | No | ||
| stock_status | No | ||
| regular_price | No | Regular price as numeric string | |
| stock_quantity | No | ||
| response_format | No | Output format: 'markdown' for human-readable text or 'json' for machine-readable structured data | markdown |