WP-CLI
The
wp sprcmcommands 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
wp sprcmFree 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.
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.
# 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| Flag | Effect |
|---|---|
--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 |
--keep | Re-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_hoursthrough the REST API. The consolidation schedule doesn't move on its own. - You're debugging and want a known-good starting point.
Related commands worth knowing
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.
| Hook | Group | Runs |
|---|---|---|
sprcm_rollup_daily | shaped-recommend | Daily: builds the figures Analytics reads |
sprcm_purge_events | shaped-recommend | Daily: deletes raw events past the retention window (90 days by default) |
sprcm_mine_consolidate Pro | shaped-recommend-pro | Every stats_cache_hours: consolidates mined pairs |
sprcm_mine_order Pro | shaped-recommend-pro | As orders are paid: incremental mining |
sprcm_license_check Pro | shaped-recommend-pro | Weekly: re-checks the license |
wp action-scheduler action list --group=shaped-recommend --status=pending
wp action-scheduler action list --group=shaped-recommend-pro --status=pendingIf 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
wp action-scheduler run --hooks=sprcm_rollup_daily --forceAction 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:
wp eval 'print_r( ShapedPlugin\ShapedRecommend\Admin\App::payload()["builder"] );' --user=1Check the tier map
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
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:
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.jsonThe 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
- Store Statistics: what the mining does.
- REST API: everything the CLI doesn't cover.
- Troubleshooting