Skip to content

WP-CLI ​

The wp sprcm commands that ship today, and the WordPress and WooCommerce commands worth knowing alongside them.

Most stores never need the command line. You'll reach for it when Store Statistics needs a nudge after an order import, when Analytics looks empty, or when you're scripting a deployment.

The namespace ​

bash
wp sprcm

Free registers the sprcm namespace and no subcommands of its own. It exists so Pro's wp sprcm stats has a parent to attach to: a Free-only install still recognises wp sprcm, and on a Free + Pro install exactly one package owns the command root.

So on a Free-only store, wp sprcm is a namespace with nothing under it. That's expected.

wp sprcm stats Pro ​

Mines and inspects the product-affinity store, the "bought together" data behind Store Statistics and the Frequently Bought Together and Others Also Bought sorts.

wp sprcm stats status ​

Reports, for each order window, whether the affinity store holds any mined data.

bash
wp sprcm stats status
+--------+-------+
| window | mined |
+--------+-------+
| 7d     | no    |
| 14d    | no    |
| 30d    | no    |
| 90d    | yes   |
| 6mo    | yes   |
| 12mo   | yes   |
| all    | yes   |
+--------+-------+

Run this first when a Store Statistics block seems to be ignoring your order data. A window reading no hasn't got enough repeat co-purchases to clear the support thresholds yet, and blocks using it are serving the Rules fallback, correctly and quietly. Short windows on a young or low-volume store are usually no.

wp sprcm stats rebuild ​

Re-mines the affinity store from your order history.

bash
# Every window, starting from an empty store
wp sprcm stats rebuild

# One window only
wp sprcm stats rebuild --window=90d

# Re-mine without emptying the store first (use this on a live store)
wp sprcm stats rebuild --window=90d --keep
FlagEffect
--window=<window>Mine one window only: 7d, 14d, 30d, 90d, 6mo, 12mo or all. Defaults to every window. An unknown value stops with an error listing the valid ones
--keepRe-mine without emptying the store first, so nothing falls back mid-pass

It prints how many eligible pairs each window produced, then a total. If nothing qualifies, it ends with a warning rather than an error, because a store below the support thresholds has nothing to mine yet, and that's the normal cold-start state, not a failure.

Use --keep on a live store

Without it, the store is emptied before re-mining, and the command says so: "Emptying the affinity store — statistics recommendations fall back to Rules until mining finishes." Between those two moments every Store Statistics block shows its Rules fallback. That's safe, but it's a visible change to your storefront for the length of the pass.

--keep re-mines over the existing data instead. Use plain rebuild on staging and --keep in production.

A full rebuild is deliberately CLI-only. No admin screen offers it, because emptying the store is a trade you should make knowingly.

When to rebuild ​

Mining normally happens on its own: incrementally as orders are paid, plus a scheduled consolidation pass on the store's stats_cache_hours cadence (24 hours by default). You'd rebuild by hand when:

  • You've imported historical orders and want them counted now rather than at the next pass.
  • Action Scheduler or WP-Cron has been stuck, and you're catching up after fixing it.
  • You've changed which order statuses count and want the pairs to reflect it.
  • You've changed stats_cache_hours through the REST API. The consolidation schedule doesn't move on its own.
  • You're debugging and want a known-good starting point.

Not part of this plugin, but the ones you'll reach for alongside it.

Check scheduled jobs ​

Both packages schedule their jobs with Action Scheduler (bundled with WooCommerce), not plain WP-Cron.

HookGroupRuns
sprcm_rollup_dailyshaped-recommendDaily: builds the figures Analytics reads
sprcm_purge_eventsshaped-recommendDaily: deletes raw events past the retention window (90 days by default)
sprcm_mine_consolidate Proshaped-recommend-proEvery stats_cache_hours: consolidates mined pairs
sprcm_mine_order Proshaped-recommend-proAs orders are paid: incremental mining
sprcm_license_check Proshaped-recommend-proWeekly: re-checks the license
bash
wp action-scheduler action list --group=shaped-recommend --status=pending
wp action-scheduler action list --group=shaped-recommend-pro --status=pending

If the daily rollup isn't listed as pending, that's why Analytics is empty. Loading any wp-admin page re-schedules a missing job.

Run a scheduled job now ​

bash
wp action-scheduler run --hooks=sprcm_rollup_daily --force

Action Scheduler also runs off WP-Cron, so if nothing ever runs, check that WP-Cron itself is firing (wp cron test).

Inspect the registries ​

The valid tokens for contexts, filters, sorts, displays and locations depend on the tier and on what's installed, so read them from the server rather than hardcoding them:

bash
wp eval 'print_r( ShapedPlugin\ShapedRecommend\Admin\App::payload()["builder"] );' --user=1

Check the tier map ​

bash
wp eval 'print_r( sprcm_capabilities() );'

Shows what this runtime actually allows. It's the fastest way to confirm whether Pro is really unlocking things.

Check the tables exist ​

bash
wp db query "SHOW TABLES LIKE '%sprcm%'"

You should see sprcm_events, sprcm_event_rollups and sprcm_affinity, each with your table prefix. Free creates all three, including sprcm_affinity. Only Pro fills it.

Export configuration from the command line ​

There's no wp sprcm export subcommand. Use the REST route:

bash
wp eval '
$r = new WP_REST_Request( "GET", "/sprcm/v1/export" );
$r->set_header( "X-WP-Nonce", wp_create_nonce( "wp_rest" ) );
echo wp_json_encode( rest_do_request( $r )->get_data()["envelope"] );
' --user=1 > sprcm-config.json

The route returns { filename, envelope }, and the envelope is the file. The nonce header matters: without it every REST call comes back 403 sprcm_invalid_nonce, which reads exactly like a broken route.

Next ​