WooCommerce · Arazzo Workflow

WooCommerce Create Category and Product

Version 1.0.0

Create a product category, create a product assigned to it, then read the product back.

1 workflow 1 source API 1 provider
View Spec View on GitHub eCommerceOpen SourceOrdersProductsWordPressArazzoWorkflows

Provider

woocommerce

Workflows

create-category-and-product
Create a category, create a product in it, and confirm the product.
Creates a product category, creates a product assigned to that category, and reads the product back to verify it was stored correctly.
3 steps inputs: categoryName, categorySlug, productName, regularPrice, sku outputs: categoryId, productId, productStatus
1
createCategory
createProductCategory
Create the product category that the new product will be assigned to.
2
createProduct
createProduct
Create a product and assign it to the category created in the previous step.
3
getProduct
getProduct
Retrieve the created product to confirm it persisted with the assigned category and pricing.

Source API Descriptions

Arazzo Workflow Specification

woocommerce-create-category-and-product-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: WooCommerce Create Category and Product
  summary: Create a product category, create a product assigned to it, then read the product back.
  description: >-
    Bootstraps a catalog entry from scratch. The workflow first creates a
    product category, then creates a product that is assigned to the newly
    created category, and finally retrieves the created product to confirm it
    persisted with its category, pricing, and stock settings. Every step spells
    out its request inline so the flow can be read and executed without opening
    the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: woocommerceRestApi
  url: ../openapi/woocommerce-rest-api-openapi.yml
  type: openapi
workflows:
- workflowId: create-category-and-product
  summary: Create a category, create a product in it, and confirm the product.
  description: >-
    Creates a product category, creates a product assigned to that category,
    and reads the product back to verify it was stored correctly.
  inputs:
    type: object
    required:
    - categoryName
    - productName
    - regularPrice
    properties:
      categoryName:
        type: string
        description: Name of the product category to create.
      categorySlug:
        type: string
        description: Optional URL-friendly slug for the category.
      productName:
        type: string
        description: Name of the product to create.
      regularPrice:
        type: string
        description: Regular price of the product as a decimal string.
      sku:
        type: string
        description: Stock-keeping unit identifier for the product.
  steps:
  - stepId: createCategory
    description: >-
      Create the product category that the new product will be assigned to.
    operationId: createProductCategory
    requestBody:
      contentType: application/json
      payload:
        name: $inputs.categoryName
        slug: $inputs.categorySlug
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      categoryId: $response.body#/id
  - stepId: createProduct
    description: >-
      Create a product and assign it to the category created in the previous
      step.
    operationId: createProduct
    requestBody:
      contentType: application/json
      payload:
        name: $inputs.productName
        type: simple
        status: publish
        regular_price: $inputs.regularPrice
        sku: $inputs.sku
        categories:
        - id: $steps.createCategory.outputs.categoryId
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      productId: $response.body#/id
  - stepId: getProduct
    description: >-
      Retrieve the created product to confirm it persisted with the assigned
      category and pricing.
    operationId: getProduct
    parameters:
    - name: id
      in: path
      value: $steps.createProduct.outputs.productId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      productId: $response.body#/id
      productName: $response.body#/name
      productStatus: $response.body#/status
  outputs:
    categoryId: $steps.createCategory.outputs.categoryId
    productId: $steps.getProduct.outputs.productId
    productStatus: $steps.getProduct.outputs.productStatus