Launch Sale — 20% off all plugins. Limited time only.

WP-CLI commands

Refinery CRM includes built-in WP-CLI commands for managing customers, segments, analytics, and email directly from the command line. These commands are useful for bulk operations, scripting, automation, and integration with AI development tools like Claude Code.

Prerequisites

  • WP-CLI version 2.5 or later
  • WooCommerce installed and active
  • A WordPress user with the manage_woocommerce capability

Customer commands

All customer commands are under the wp refinery crm customer namespace.

List customers

wp refinery crm customer list
wp refinery crm customer list --search="john" --per_page=50
wp refinery crm customer list --orderby=total_spend --order=DESC --format=json

Options:

  • --search=<term> — Filter by name or email
  • --per_page=<number> — Results per page (default: 20)
  • --page=<number> — Page number (default: 1)
  • --orderby=<field> — Sort by date_last_active, date_registered, name, email, total_spend, or orders_count
  • --order=<direction>ASC or DESC (default: DESC)
  • --format=<format>table, json, csv, or count

Get a customer

Display a single customer’s full profile, including billing address and order stats. Use a numeric user ID for registered customers or guest_XX for guest customers.

wp refinery crm customer get 42
wp refinery crm customer get guest_5 --format=json

List customer orders

Display a customer’s order history with line items.

wp refinery crm customer orders 42
wp refinery crm customer orders 42 --per_page=50 --format=csv

Segment commands

All segment commands are under the wp refinery crm segment namespace.

List segments

Display all customer segments with their customer counts.

wp refinery crm segment list
wp refinery crm segment list --format=json

Get a segment

Display a single segment’s details, including its filter rules.

wp refinery crm segment get 1

List segment customers

List the customers that match a segment’s rules.

wp refinery crm segment customers 1 --per_page=50

Create a segment

Create a new customer segment. Pass filter rules as a JSON string.

wp refinery crm segment create --name="High Spenders" --description="Customers who spent over $500" --rules='[{"field":"total_spent","operator":"greater_than","value":"500"}]'

Options:

  • --name=<name> — Segment name (required)
  • --description=<text> — Segment description
  • --rules=<json> — Filter rules as a JSON array

Delete a segment

Delete a segment. Add --yes to skip the confirmation prompt.

wp refinery crm segment delete 3 --yes

Analytics

Display store-wide customer analytics including growth, returning vs. new customers, and period comparisons.

wp refinery crm analytics
wp refinery crm analytics --date_range=quarter --comparison=previous_year --format=json

Options:

  • --date_range=<range>week, month, quarter, or year (default: month)
  • --comparison=<type>previous_period or previous_year
  • --format=<format>table or json

Send email

Send an email to a customer using WooCommerce email templates. A confirmation prompt appears unless --yes is passed.

wp refinery crm send-email --to="[email protected]" --name="John" --subject="Your order update" --message="Your order has shipped!" --yes

All four parameters (--to, --name, --subject, --message) are required.

Settings

Display current CRM settings.

wp refinery crm settings
wp refinery crm settings --format=json

Grow Your Store Smarter

One email a week with plugin updates, revenue tactics, and strategies top WooCommerce stores use to scale.

By subscribing, you agree to our Privacy Policy. Unsubscribe anytime.

Item added to cart.
0 items - $0.00