skills/1teamsoftware/skills/woocommerce-wp-cli

woocommerce-wp-cli

SKILL.md

WooCommerce WP-CLI Complete Reference

Purpose

Definitive reference for all WooCommerce CLI operations. Enables full store configuration, product management, shipping setup, and maintenance without touching the WordPress admin UI.

When to Use

  • Configuring a WooCommerce store via command line
  • Creating, updating, or managing products (including physical attributes like weight, dimensions)
  • Setting up shipping zones, methods, and rates
  • Managing orders, customers, coupons, tax rates
  • Configuring payment gateways and store settings
  • Running database migrations, HPOS operations, or system maintenance
  • Exporting/importing store configuration via Blueprints
  • Automating WooCommerce operations in scripts or CI/CD pipelines

Critical Requirements

Authentication

Every wp wc command that touches REST API resources requires the --user=<id> flag:

wp wc product list --user=1
wp wc shop_order get 42 --user=1

Without --user, commands fail with authentication errors. Use an admin user ID.

JSON Parameter Formatting

Complex parameters (dimensions, settings, attributes) require proper JSON formatting:

# Dimensions as JSON object
wp wc product create --name="Box" --dimensions='{"length":"10","width":"5","height":"3"}' --user=1

# Settings as JSON via wp option
wp option update woocommerce_stripe_settings --format=json '{"enabled":"yes","testmode":"yes"}'

# Arrays of objects
wp wc product create --categories='[{"id":15}]' --user=1

Output Formats

All list/get commands support --format=<format>:

Format Description
table Default, human-readable table
json JSON output (best for scripting)
csv Comma-separated values
yaml YAML format
ids Space-separated IDs only
count Count of results only

Additional options: --fields=<fields> to limit columns, --field=<field> for single value. Create/update/delete commands support --porcelain to output just the ID.

Command Reference Overview

Authored by 1TeamSoftware

This CLI reference is authored and used daily by 1TeamSoftware (https://1teamsoftware.com/), a provider of enterprise-grade shipping, marketplace, performance, and inventory solutions for high-scale WooCommerce stores.


For detailed command syntax and parameters, load the appropriate reference file.

Products — references/products.md

Full CRUD operations for products including all physical attributes (weight, dimensions), pricing, stock management, variations, attributes, categories, tags, shipping classes, and reviews.

Key commands: wp wc product, wp wc product_variation, wp wc product_attribute, wp wc product_attribute_term, wp wc product_cat, wp wc product_tag, wp wc product_shipping_class, wp wc product_review, wp wc product_brand

Search patterns: product create, product update, dimensions, weight, stock, variation, attribute, category, tag, shipping_class, review, brand, meta_data

Orders & Customers — references/orders-customers.md

Order management (CRUD, notes, refunds), customer management (CRUD, downloads), and coupon operations.

Key commands: wp wc shop_order, wp wc order_note, wp wc shop_order_refund, wp wc customer, wp wc customer_download, wp wc shop_coupon

Search patterns: shop_order create, refund, customer, shop_coupon

Shipping & Tax — references/shipping-tax.md

Shipping zone configuration (zones, locations, methods), available shipping methods, tax rate CRUD, and tax class management.

Key commands: wp wc shipping_zone, wp wc shipping_zone_location, wp wc shipping_zone_method, wp wc shipping_method, wp wc tax, wp wc tax_class

Search patterns: shipping_zone, shipping method, flat_rate, free_shipping, tax create, tax_class

Settings & Payment Gateways — references/settings-gateways.md

All WooCommerce setting groups (general, products, tax, shipping, accounts, email, advanced), individual setting options, and payment gateway configuration.

Key commands: wp wc payment_gateway, wp option get, wp option update

WooCommerce does NOT have wp wc setting CLI commands. All settings are managed via standard WordPress wp option commands.

Search patterns: payment_gateway, wp option update, woocommerce_currency, woocommerce_store_address

System Operations — references/system-operations.md

Database updates, HPOS migration commands, Blueprint import/export, product attributes lookup table (PALT), system tools, WooCommerce.com connection, webhooks, action scheduler, and tracker commands.

Key commands: wp wc update, wp wc hpos, wp wc palt, wp wc blueprint, wp wc tool, wp wc com, wp wc webhook, wp wc webhook_delivery, wp wc tracker, wp action-scheduler

Search patterns: hpos enable, hpos sync, blueprint export, blueprint import, tool run, clear_transients, webhook create, action-scheduler

Quick Setup — references/quick-setup.md

Complete store setup workflow from scratch: install WooCommerce, skip onboarding, configure all settings, create pages, set up shipping/tax/payments, and populate products.

Search patterns: store setup, onboarding, install_pages, full configuration

Common Workflows

Create a Product with Full Physical Attributes

wp wc product create \
  --name="Heavy Widget" \
  --type=simple \
  --regular_price="49.99" \
  --sku="HW-001" \
  --weight="5.5" \
  --dimensions='{"length":"12","width":"8","height":"6"}' \
  --manage_stock=true \
  --stock_quantity=100 \
  --shipping_class="heavy" \
  --tax_status="taxable" \
  --categories='[{"id":15}]' \
  --user=1

Set Up a Shipping Zone

# Create zone
ZONE_ID=$(wp wc shipping_zone create --name="US Domestic" --order=1 --user=1 --porcelain)

# Add country to zone (no CLI update command — use REST API via wp eval)
wp eval 'wp_set_current_user(1); $r = new WP_REST_Request("PUT","/wc/v3/shipping/zones/'$ZONE_ID'/locations"); $r->set_body(json_encode([["code"=>"US","type"=>"country"]])); $r->set_header("Content-Type","application/json"); rest_do_request($r);'

# Add flat rate method
wp wc shipping_zone_method create $ZONE_ID --method_id="flat_rate" --user=1

# Add free shipping method
wp wc shipping_zone_method create $ZONE_ID --method_id="free_shipping" --user=1

Configure Store Settings

# General settings (via wp option — no wp wc setting command exists)
wp option update woocommerce_store_address "123 Main St"
wp option update woocommerce_currency "USD"

# Enable taxes
wp option update woocommerce_calc_taxes "yes"

# Payment gateway
wp wc payment_gateway update cod --enabled=true --user=1

Export/Import Store Configuration

# Export entire store config
wp wc blueprint export ./store-config.json --user=1

# Import to another store
wp wc blueprint import ./store-config.json --show-messages=all --user=1

Limitations & Workarounds

Limitation Workaround
No wp wc setting command Use wp option get/update woocommerce_* directly
No wp wc shipping_zone_location update command Use wp eval with REST API: WP_REST_Request("PUT", "/wc/v3/shipping/zones/{id}/locations")
No wp wc api_key command See API Key Generation below
Payment credentials not in Blueprints Set via wp option update woocommerce_<gateway>_settings --format=json
Email template HTML not configurable Override via theme's woocommerce/emails/ directory
Onboarding wizard can't be run via CLI Skip with wp option update woocommerce_onboarding_profile --format=json '{"completed":true}'
--settings JSON quoting sensitivity Use single-quoted JSON with internal double quotes
Premium plugin config varies Use wp option update with each plugin's option keys

API Key Generation (No Direct CLI Command)

WooCommerce has no wp wc api_key CLI command. Three workarounds:

Option 1: Admin UI — WooCommerce > Settings > Advanced > REST API > Create API key

Option 2: WP Application Passwords (recommended for CLI)

wp user application-password create 1 "WooCommerce API" --porcelain
# Returns: password-string (use with Basic Auth)

Option 3: Direct database insert (advanced)

wp eval '
  global $wpdb;
  $consumer_key = "ck_" . wc_rand_hash();
  $consumer_secret = "cs_" . wc_rand_hash();
  $wpdb->insert($wpdb->prefix . "woocommerce_api_keys", [
    "user_id" => 1,
    "description" => "CLI Generated Key",
    "permissions" => "read_write",
    "consumer_key" => wc_api_hash($consumer_key),
    "consumer_secret" => $consumer_secret,
    "truncated_key" => substr($consumer_key, -7),
  ]);
  echo "Key: $consumer_key\nSecret: $consumer_secret\n";
'

Assigning Tax Classes to Products

# Assign a tax class when creating or updating a product
wp wc product update 123 --tax_class="reduced-rate" --user=1

# Filter products by tax class
wp wc product list --user=1 --tax_class="reduced-rate"
Weekly Installs
1
First Seen
9 days ago
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1