{ "kind": "open-flow-workflow", "version": 1, "name": "Create a WooCommerce Product and Set Stock", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_cf47067355736a02": { "name": "Create a product", "kind": "start", "inputDefs": [] }, "n_3657333c26f2e346": { "inputs": { "name": { "kind": "value", "value": "n8n Sweatshirt" }, "description": { "kind": "value", "value": "Stay warm with this sweatshirt!" }, "regularPrice": { "kind": "value", "value": "30" } }, "name": "Create the product", "kind": "task", "task": { "inputs": [ { "description": "The product name.", "jsonSchema": { "type": "string", "description": "The product name." }, "nullable": false, "handle": "name" }, { "description": "The WooCommerce product type, such as simple or variable.", "jsonSchema": { "type": "string", "description": "The WooCommerce product type, such as simple or variable." }, "nullable": true, "handle": "type", "value": null }, { "description": "The WooCommerce product status.", "jsonSchema": { "type": "string", "enum": [ "any", "draft", "pending", "private", "publish" ], "description": "The WooCommerce product status." }, "nullable": true, "handle": "status", "value": null }, { "description": "The product SKU.", "jsonSchema": { "type": "string", "description": "The product SKU." }, "nullable": true, "handle": "sku", "value": null }, { "description": "The regular product price as a decimal string.", "jsonSchema": { "type": "string", "description": "The regular product price as a decimal string." }, "nullable": true, "handle": "regularPrice", "value": null }, { "description": "The sale product price as a decimal string.", "jsonSchema": { "type": "string", "description": "The sale product price as a decimal string." }, "nullable": true, "handle": "salePrice", "value": null }, { "description": "The full product description.", "jsonSchema": { "type": "string", "description": "The full product description." }, "nullable": true, "handle": "description", "value": null }, { "description": "The short product description.", "jsonSchema": { "type": "string", "description": "The short product description." }, "nullable": true, "handle": "shortDescription", "value": null }, { "description": "Whether WooCommerce should manage stock for this product.", "jsonSchema": { "type": "boolean", "description": "Whether WooCommerce should manage stock for this product." }, "nullable": true, "handle": "manageStock", "value": null }, { "description": "The product stock quantity.", "jsonSchema": { "type": "integer", "description": "The product stock quantity." }, "nullable": true, "handle": "stockQuantity", "value": null }, { "description": "The WooCommerce stock status.", "jsonSchema": { "type": "string", "enum": [ "instock", "outofstock", "onbackorder" ], "description": "The WooCommerce stock status." }, "nullable": true, "handle": "stockStatus", "value": null }, { "description": "The product category references.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The WooCommerce term ID." } }, "required": [ "id" ], "additionalProperties": false, "description": "A WooCommerce taxonomy term reference used in write payloads." }, "description": "The product category references." }, "nullable": true, "handle": "categories", "value": null }, { "description": "The product tag references.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The WooCommerce term ID." } }, "required": [ "id" ], "additionalProperties": false, "description": "A WooCommerce taxonomy term reference used in write payloads." }, "description": "The product tag references." }, "nullable": true, "handle": "tags", "value": null }, { "description": "The product image references.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The existing WordPress media attachment ID." }, "src": { "type": "string", "description": "A public image URL WooCommerce can import." }, "name": { "type": "string", "description": "The image display name." }, "alt": { "type": "string", "description": "The image alt text." } }, "additionalProperties": false, "description": "A WooCommerce product image reference used in write payloads." }, "description": "The product image references." }, "nullable": true, "handle": "images", "value": null }, { "description": "The product attributes.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The existing WooCommerce attribute ID." }, "name": { "type": "string", "description": "The custom attribute name when no attribute ID is used." }, "position": { "type": "integer", "description": "The attribute display position." }, "visible": { "type": "boolean", "description": "Whether the attribute is visible on the product page." }, "variation": { "type": "boolean", "description": "Whether the attribute is used for variations." }, "options": { "type": "array", "items": { "type": "string", "description": "One attribute option." }, "description": "The attribute option labels." } }, "additionalProperties": false, "description": "A WooCommerce product attribute payload used in product writes." }, "description": "The product attributes." }, "nullable": true, "handle": "attributes", "value": null } ], "outputs": [ { "description": "The WooCommerce product ID.", "jsonSchema": { "type": [ "integer", "null" ], "description": "The WooCommerce product ID." }, "nullable": true, "handle": "id" }, { "description": "The product name.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product name." }, "nullable": true, "handle": "name" }, { "description": "The product URL slug.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product URL slug." }, "nullable": true, "handle": "slug" }, { "description": "The product permalink.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product permalink." }, "nullable": true, "handle": "permalink" }, { "description": "The WooCommerce product type.", "jsonSchema": { "type": [ "string", "null" ], "description": "The WooCommerce product type." }, "nullable": true, "handle": "type" }, { "description": "The product status.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product status." }, "nullable": true, "handle": "status" }, { "description": "The product SKU.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product SKU." }, "nullable": true, "handle": "sku" }, { "description": "The current product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The current product price as returned by WooCommerce." }, "nullable": true, "handle": "price" }, { "description": "The regular product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The regular product price as returned by WooCommerce." }, "nullable": true, "handle": "regularPrice" }, { "description": "The sale product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The sale product price as returned by WooCommerce." }, "nullable": true, "handle": "salePrice" }, { "description": "The product stock status.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product stock status." }, "nullable": true, "handle": "stockStatus" }, { "description": "The product stock quantity, if tracked.", "jsonSchema": { "type": [ "integer", "null" ], "description": "The product stock quantity, if tracked." }, "nullable": true, "handle": "stockQuantity" }, { "description": "The product categories returned by WooCommerce.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": [ "integer", "null" ], "description": "The WooCommerce category ID." }, "name": { "type": [ "string", "null" ], "description": "The category display name." }, "slug": { "type": [ "string", "null" ], "description": "The category URL slug." } }, "required": [ "id", "name", "slug" ], "additionalProperties": false, "description": "One WooCommerce product category attached to a product." }, "description": "The product categories returned by WooCommerce." }, "nullable": false, "handle": "categories" }, { "description": "The product images returned by WooCommerce.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": [ "integer", "null" ], "description": "The WooCommerce image attachment ID." }, "src": { "type": [ "string", "null" ], "description": "The image URL." }, "name": { "type": [ "string", "null" ], "description": "The image display name." }, "alt": { "type": [ "string", "null" ], "description": "The image alt text." } }, "required": [ "id", "src", "name", "alt" ], "additionalProperties": false, "description": "One WooCommerce product image." }, "description": "The product images returned by WooCommerce." }, "nullable": false, "handle": "images" } ], "name": "Create the product", "executor": { "kind": "connector", "action": "woocommerce.create_product" } } }, "n_78ac75c9a2cd7641": { "inputs": { "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3657333c26f2e346", "output": "id" } ] } }, "name": "Use the created product ID", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": [ "integer", "null" ], "description": "The WooCommerce product ID." }, "nullable": true, "handle": "id" } ], "outputs": [ { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "id" } ], "name": "Use the created product ID", "moduleId": "n_896fee48e220da8f", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_a7ba984dc9150922": { "inputs": { "productId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_78ac75c9a2cd7641", "output": "id" } ] }, "manageStock": { "kind": "value", "value": true }, "stockQuantity": { "kind": "value", "value": 100 } }, "name": "Set stock to 100", "kind": "task", "task": { "inputs": [ { "description": "The WooCommerce product ID to update.", "jsonSchema": { "type": "integer", "minimum": 1, "description": "The WooCommerce product ID to update." }, "nullable": false, "handle": "productId" }, { "description": "The product name.", "jsonSchema": { "type": "string", "description": "The product name." }, "nullable": true, "handle": "name", "value": null }, { "description": "The WooCommerce product type, such as simple or variable.", "jsonSchema": { "type": "string", "description": "The WooCommerce product type, such as simple or variable." }, "nullable": true, "handle": "type", "value": null }, { "description": "The WooCommerce product status.", "jsonSchema": { "type": "string", "enum": [ "any", "draft", "pending", "private", "publish" ], "description": "The WooCommerce product status." }, "nullable": true, "handle": "status", "value": null }, { "description": "The product SKU.", "jsonSchema": { "type": "string", "description": "The product SKU." }, "nullable": true, "handle": "sku", "value": null }, { "description": "The regular product price as a decimal string.", "jsonSchema": { "type": "string", "description": "The regular product price as a decimal string." }, "nullable": true, "handle": "regularPrice", "value": null }, { "description": "The sale product price as a decimal string.", "jsonSchema": { "type": "string", "description": "The sale product price as a decimal string." }, "nullable": true, "handle": "salePrice", "value": null }, { "description": "The full product description.", "jsonSchema": { "type": "string", "description": "The full product description." }, "nullable": true, "handle": "description", "value": null }, { "description": "The short product description.", "jsonSchema": { "type": "string", "description": "The short product description." }, "nullable": true, "handle": "shortDescription", "value": null }, { "description": "Whether WooCommerce should manage stock for this product.", "jsonSchema": { "type": "boolean", "description": "Whether WooCommerce should manage stock for this product." }, "nullable": true, "handle": "manageStock", "value": null }, { "description": "The product stock quantity.", "jsonSchema": { "type": "integer", "description": "The product stock quantity." }, "nullable": true, "handle": "stockQuantity", "value": null }, { "description": "The WooCommerce stock status.", "jsonSchema": { "type": "string", "enum": [ "instock", "outofstock", "onbackorder" ], "description": "The WooCommerce stock status." }, "nullable": true, "handle": "stockStatus", "value": null }, { "description": "The product category references.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The WooCommerce term ID." } }, "required": [ "id" ], "additionalProperties": false, "description": "A WooCommerce taxonomy term reference used in write payloads." }, "description": "The product category references." }, "nullable": true, "handle": "categories", "value": null }, { "description": "The product tag references.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The WooCommerce term ID." } }, "required": [ "id" ], "additionalProperties": false, "description": "A WooCommerce taxonomy term reference used in write payloads." }, "description": "The product tag references." }, "nullable": true, "handle": "tags", "value": null }, { "description": "The product image references.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The existing WordPress media attachment ID." }, "src": { "type": "string", "description": "A public image URL WooCommerce can import." }, "name": { "type": "string", "description": "The image display name." }, "alt": { "type": "string", "description": "The image alt text." } }, "additionalProperties": false, "description": "A WooCommerce product image reference used in write payloads." }, "description": "The product image references." }, "nullable": true, "handle": "images", "value": null }, { "description": "The product attributes.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1, "description": "The existing WooCommerce attribute ID." }, "name": { "type": "string", "description": "The custom attribute name when no attribute ID is used." }, "position": { "type": "integer", "description": "The attribute display position." }, "visible": { "type": "boolean", "description": "Whether the attribute is visible on the product page." }, "variation": { "type": "boolean", "description": "Whether the attribute is used for variations." }, "options": { "type": "array", "items": { "type": "string", "description": "One attribute option." }, "description": "The attribute option labels." } }, "additionalProperties": false, "description": "A WooCommerce product attribute payload used in product writes." }, "description": "The product attributes." }, "nullable": true, "handle": "attributes", "value": null } ], "outputs": [ { "description": "The WooCommerce product ID.", "jsonSchema": { "type": [ "integer", "null" ], "description": "The WooCommerce product ID." }, "nullable": true, "handle": "id" }, { "description": "The product name.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product name." }, "nullable": true, "handle": "name" }, { "description": "The product URL slug.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product URL slug." }, "nullable": true, "handle": "slug" }, { "description": "The product permalink.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product permalink." }, "nullable": true, "handle": "permalink" }, { "description": "The WooCommerce product type.", "jsonSchema": { "type": [ "string", "null" ], "description": "The WooCommerce product type." }, "nullable": true, "handle": "type" }, { "description": "The product status.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product status." }, "nullable": true, "handle": "status" }, { "description": "The product SKU.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product SKU." }, "nullable": true, "handle": "sku" }, { "description": "The current product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The current product price as returned by WooCommerce." }, "nullable": true, "handle": "price" }, { "description": "The regular product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The regular product price as returned by WooCommerce." }, "nullable": true, "handle": "regularPrice" }, { "description": "The sale product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The sale product price as returned by WooCommerce." }, "nullable": true, "handle": "salePrice" }, { "description": "The product stock status.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product stock status." }, "nullable": true, "handle": "stockStatus" }, { "description": "The product stock quantity, if tracked.", "jsonSchema": { "type": [ "integer", "null" ], "description": "The product stock quantity, if tracked." }, "nullable": true, "handle": "stockQuantity" }, { "description": "The product categories returned by WooCommerce.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": [ "integer", "null" ], "description": "The WooCommerce category ID." }, "name": { "type": [ "string", "null" ], "description": "The category display name." }, "slug": { "type": [ "string", "null" ], "description": "The category URL slug." } }, "required": [ "id", "name", "slug" ], "additionalProperties": false, "description": "One WooCommerce product category attached to a product." }, "description": "The product categories returned by WooCommerce." }, "nullable": false, "handle": "categories" }, { "description": "The product images returned by WooCommerce.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": [ "integer", "null" ], "description": "The WooCommerce image attachment ID." }, "src": { "type": [ "string", "null" ], "description": "The image URL." }, "name": { "type": [ "string", "null" ], "description": "The image display name." }, "alt": { "type": [ "string", "null" ], "description": "The image alt text." } }, "required": [ "id", "src", "name", "alt" ], "additionalProperties": false, "description": "One WooCommerce product image." }, "description": "The product images returned by WooCommerce." }, "nullable": false, "handle": "images" } ], "name": "Set stock to 100", "executor": { "kind": "connector", "action": "woocommerce.update_product" } } }, "n_ce7afe164da16675": { "inputs": { "productId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_78ac75c9a2cd7641", "output": "id" } ] } }, "name": "Read the same product", "kind": "task", "task": { "inputs": [ { "description": "The WooCommerce product ID to fetch.", "jsonSchema": { "type": "integer", "minimum": 1, "description": "The WooCommerce product ID to fetch." }, "nullable": false, "handle": "productId" } ], "outputs": [ { "description": "The WooCommerce product ID.", "jsonSchema": { "type": [ "integer", "null" ], "description": "The WooCommerce product ID." }, "nullable": true, "handle": "id" }, { "description": "The product name.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product name." }, "nullable": true, "handle": "name" }, { "description": "The product URL slug.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product URL slug." }, "nullable": true, "handle": "slug" }, { "description": "The product permalink.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product permalink." }, "nullable": true, "handle": "permalink" }, { "description": "The WooCommerce product type.", "jsonSchema": { "type": [ "string", "null" ], "description": "The WooCommerce product type." }, "nullable": true, "handle": "type" }, { "description": "The product status.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product status." }, "nullable": true, "handle": "status" }, { "description": "The product SKU.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product SKU." }, "nullable": true, "handle": "sku" }, { "description": "The current product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The current product price as returned by WooCommerce." }, "nullable": true, "handle": "price" }, { "description": "The regular product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The regular product price as returned by WooCommerce." }, "nullable": true, "handle": "regularPrice" }, { "description": "The sale product price as returned by WooCommerce.", "jsonSchema": { "type": [ "string", "null" ], "description": "The sale product price as returned by WooCommerce." }, "nullable": true, "handle": "salePrice" }, { "description": "The product stock status.", "jsonSchema": { "type": [ "string", "null" ], "description": "The product stock status." }, "nullable": true, "handle": "stockStatus" }, { "description": "The product stock quantity, if tracked.", "jsonSchema": { "type": [ "integer", "null" ], "description": "The product stock quantity, if tracked." }, "nullable": true, "handle": "stockQuantity" }, { "description": "The product categories returned by WooCommerce.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": [ "integer", "null" ], "description": "The WooCommerce category ID." }, "name": { "type": [ "string", "null" ], "description": "The category display name." }, "slug": { "type": [ "string", "null" ], "description": "The category URL slug." } }, "required": [ "id", "name", "slug" ], "additionalProperties": false, "description": "One WooCommerce product category attached to a product." }, "description": "The product categories returned by WooCommerce." }, "nullable": false, "handle": "categories" }, { "description": "The product images returned by WooCommerce.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": [ "integer", "null" ], "description": "The WooCommerce image attachment ID." }, "src": { "type": [ "string", "null" ], "description": "The image URL." }, "name": { "type": [ "string", "null" ], "description": "The image display name." }, "alt": { "type": [ "string", "null" ], "description": "The image alt text." } }, "required": [ "id", "src", "name", "alt" ], "additionalProperties": false, "description": "One WooCommerce product image." }, "description": "The product images returned by WooCommerce." }, "nullable": false, "handle": "images" } ], "name": "Read the same product", "executor": { "kind": "connector", "action": "woocommerce.get_product" } } }, "n_226fc686e190774e": { "name": "Product ID and stock", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": [ "integer", "null" ], "description": "The WooCommerce product ID." }, "nullable": true, "handle": "id" }, { "jsonSchema": { "type": [ "string", "null" ], "description": "The product name." }, "nullable": true, "handle": "name" }, { "jsonSchema": { "type": [ "integer", "null" ], "description": "The product stock quantity, if tracked." }, "nullable": true, "handle": "stockQuantity" } ], "outputMappings": { "id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ce7afe164da16675", "output": "id" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ce7afe164da16675", "output": "name" } ] }, "stockQuantity": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ce7afe164da16675", "output": "stockQuantity" } ] } } } }, "edges": [ { "source": "n_cf47067355736a02", "target": "n_3657333c26f2e346" }, { "source": "n_3657333c26f2e346", "target": "n_78ac75c9a2cd7641" }, { "source": "n_78ac75c9a2cd7641", "target": "n_a7ba984dc9150922" }, { "source": "n_a7ba984dc9150922", "target": "n_ce7afe164da16675" }, { "source": "n_ce7afe164da16675", "target": "n_226fc686e190774e" } ] } }, "modules": { "n_896fee48e220da8f": { "name": "Use the created product ID", "imports": [], "source": "export default function productId({ id }) {\n if (!Number.isSafeInteger(id) || id <= 0) throw new Error('WooCommerce did not return a valid product ID');\n return { id };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }