woocommerce/wc-smooth-generator

A smooth product, order, customer, and coupon generator for WooCommerce.

Maintainers

Package info

github.com/woocommerce/wc-smooth-generator

Homepage

Type:wordpress-plugin

pkg:composer/woocommerce/wc-smooth-generator

Statistics

Installs: 18 771

Dependents: 0

Suggesters: 0

Stars: 373

Open Issues: 22

1.3.0 2026-02-20 15:06 UTC

README

Generate realistic WooCommerce products, orders, customers, coupons, and taxonomy terms for development, testing, and demos.

WP-CLI is the primary interface. A limited WP Admin UI is also available at Dashboard > Tools > WooCommerce Smooth Generator.

Installation

From GitHub releases (recommended):

  1. Download the latest zip from GitHub Releases.
  2. Install via WP Admin > Plugins > Add New > Upload Plugin.

From source:

git clone https://github.com/woocommerce/wc-smooth-generator.git
cd wc-smooth-generator
composer install --no-dev

Requirements

  • PHP 7.4+
  • WordPress (tested up to 6.9)
  • WooCommerce 5.0+

WP-CLI commands

All commands use the wp wc generate prefix. Run wp help wc generate for a summary, or wp help wc generate <command> for detailed usage.

Products

# Generate 10 products (default, mix of simple and variable)
wp wc generate products

# Generate 25 simple products
wp wc generate products 25 --type=simple

# Generate variable products using only existing categories and tags
wp wc generate products 10 --type=variable --use-existing-terms
Option Description
<amount> Number of products to generate. Default: 10
--type=<type> Product type: simple or variable. Default: random mix
--use-existing-terms Only use existing categories and tags instead of generating new ones

Orders

# Generate 10 orders for today's date
wp wc generate orders

# Generate orders with random dates in a range
wp wc generate orders 50 --date-start=2024-01-01 --date-end=2024-12-31

# Generate completed orders with a specific status
wp wc generate orders 20 --status=completed

# Apply coupons to half the orders
wp wc generate orders 100 --coupon-ratio=0.5

# Refund 30% of completed orders
wp wc generate orders 50 --status=completed --refund-ratio=0.3
Option Description
<amount> Number of orders to generate. Default: 10
--date-start=<date> Earliest order date (YYYY-MM-DD). Dates are randomized between this and today or --date-end
--date-end=<date> Latest order date (YYYY-MM-DD). Requires --date-start
--status=<status> Order status: completed, processing, on-hold, or failed. Default: random mix
--coupons Apply a coupon to every order. Equivalent to --coupon-ratio=1.0
--coupon-ratio=<ratio> Fraction of orders that get coupons (0.0-1.0). Creates 6 coupons if none exist (3 fixed cart, 3 percentage)
--refund-ratio=<ratio> Fraction of completed orders to refund (0.0-1.0). In batch mode: 50% full, 25% partial, 25% multi-partial. Single-order mode uses probabilistic distribution
--skip-order-attribution Skip generating order attribution metadata

Batch distribution: When generating multiple orders, coupon and refund counts are deterministic (selection without replacement). For odd totals, round() distributes coupons and remainders go to multi-partial refunds. Single-order generation uses probabilistic distribution.

Order attribution: Random attribution metadata (device type, UTM parameters, referrer, session data) is added by default. Orders dated before 2024-01-09 skip attribution, since the feature didn't exist in WooCommerce yet.

Customers

# Generate 10 customers (70% people, 30% companies)
wp wc generate customers

# Generate Spanish company customers
wp wc generate customers 20 --country=ES --type=company
Option Description
<amount> Number of customers to generate. Default: 10
--country=<code> ISO 3166-1 alpha-2 country code (e.g., US, ES, CN). Localizes names and addresses. Default: random from store selling locations
--type=<type> Customer type: person or company. Default: 70/30 mix

Coupons

# Generate 10 coupons with default discount range (5-100)
wp wc generate coupons

# Generate percentage coupons between 5% and 25%
wp wc generate coupons 20 --discount_type=percent --min=5 --max=25
Option Description
<amount> Number of coupons to generate. Default: 10
--min=<amount> Minimum discount amount. Default: 5
--max=<amount> Maximum discount amount. Default: 100
--discount_type=<type> Discount type: fixed_cart or percent. Default: fixed_cart

Terms

# Generate 10 product tags
wp wc generate terms product_tag 10

# Generate hierarchical product categories
wp wc generate terms product_cat 50 --max-depth=3

# Generate child categories under an existing category
wp wc generate terms product_cat 10 --parent=123
Option Description
<taxonomy> Required. Taxonomy to generate terms for: product_cat or product_tag
<amount> Number of terms to generate. Default: 10
--max-depth=<levels> Maximum hierarchy depth (1-5). Only applies to product_cat. Default: 1 (flat)
--parent=<term_id> Create all terms as children of this existing term ID. Only applies to product_cat

Programmatic usage

All generators live in the WC\SmoothGenerator\Generator namespace and expose generate() and batch() static methods.

Single objects

use WC\SmoothGenerator\Generator;

// Generate and save a product (returns WC_Product or WP_Error).
$product = Generator\Product::generate( true, [ 'type' => 'simple' ] );

// Generate and save an order (returns WC_Order or false).
$order = Generator\Order::generate( true, [ 'status' => 'completed' ] );

// Generate and save a customer (returns WC_Customer or WP_Error).
$customer = Generator\Customer::generate( true, [ 'country' => 'US', 'type' => 'person' ] );

// Generate and save a coupon (returns WC_Coupon or WP_Error).
$coupon = Generator\Coupon::generate( true, [ 'min' => 5, 'max' => 25, 'discount_type' => 'percent' ] );

// Generate and save a term (returns WP_Term or WP_Error).
$term = Generator\Term::generate( true, 'product_cat', 0 );

Batch generation

use WC\SmoothGenerator\Generator;

// Generate 50 products (returns array of product IDs or WP_Error).
// Max batch size: 100.
$product_ids = Generator\Product::batch( 50, [ 'type' => 'variable', 'use-existing-terms' => true ] );

// Generate 100 orders with date range and coupons.
$order_ids = Generator\Order::batch( 100, [
    'date-start'   => '2024-01-01',
    'date-end'     => '2024-06-30',
    'status'       => 'completed',
    'coupon-ratio' => '0.3',
    'refund-ratio' => '0.2',
] );

// Generate 25 customers.
$customer_ids = Generator\Customer::batch( 25, [ 'country' => 'ES' ] );

// Generate 10 coupons.
$coupon_ids = Generator\Coupon::batch( 10, [ 'min' => 1, 'max' => 50 ] );

// Generate 20 hierarchical product categories.
$term_ids = Generator\Term::batch( 20, 'product_cat', [ 'max-depth' => 3 ] );

Action hooks

Each generator fires an action after creating an object:

  • smoothgenerator_product_generated -- after a product is saved
  • smoothgenerator_order_generated -- after an order is saved
  • smoothgenerator_customer_generated -- after a customer is saved
  • smoothgenerator_coupon_generated -- after a coupon is saved
  • smoothgenerator_term_generated -- after a term is saved

Available generators

Product generator

Creates simple or variable products with:

  • Name, SKU, global unique ID, featured status
  • Price, sale price, sale date scheduling
  • Tax status and class, stock management
  • Product image and gallery images (auto-generated)
  • Categories, tags, and brands (if the product_brand taxonomy exists)
  • Upsells and cross-sells from existing products
  • Attributes and variations (for variable products)
  • Virtual/downloadable flags, dimensions, weight
  • Cost of Goods Sold (if WooCommerce COGS is enabled)
  • Reviews allowed toggle, purchase notes, menu order

Order generator

Creates orders with realistic data:

  • Billing and shipping addresses from the customer
  • Line items from existing products
  • Random status distribution (or a specific status)
  • Date randomization within a given range
  • Coupon application with configurable ratio
  • Refunds: full, partial, and multi-partial with realistic timing
  • Order attribution: device type, UTM parameters, referrer, session data
  • Extra fees (~20% chance per order)
  • Paid and completed dates based on status

Customer generator

Creates customer accounts with localized data:

  • Person (first/last name) or company profiles
  • Localized names, emails, and phone numbers based on country
  • Billing address with street, city, state, postcode
  • Shipping address (50% chance; half copy billing, half are unique)
  • Username and password

Coupon generator

Creates discount coupons:

  • Auto-generated coupon codes
  • Configurable discount range (min/max)
  • Fixed cart or percentage discount type

Term generator

Creates taxonomy terms for products:

  • Product categories (product_cat) with optional hierarchy (up to 5 levels deep)
  • Product tags (product_tag)
  • Auto-generated descriptions
  • Child terms under a specified parent

Contributing

Found a bug or want a feature? Open an issue or submit a pull request.

Development setup

Requires Node.js v16 and Composer v2+.

npm run setup

This installs dependencies and sets up a pre-commit hook that lints PHP changes using the WooCommerce Core phpcs ruleset.

License

GPL-3.0-or-later