Developers
Pro also uses the free plugin's hooks. See the free plugin's developer page.
REST API
GET /wc/v3/orders (and /wc/v2/orders) accept the same rules as the orders screen. They are listed in the endpoint's schema.
/wp-json/wc/v3/orders?sobp_rules[0][field]=product&sobp_rules[0][mode]=all&sobp_rules[0][values]=12,34&sobp_statuses[]=wc-processing
| Parameter | Value |
|---|---|
sobp_rules | Array of rules: field (product, category, tag, brand, sku, attribute, quantity, item_count), mode (any, all, only, none), values (comma-separated ids, pa_size:l pairs or SKU text) and for quantity and item_count rules op (gte, lte, eq) and number |
sobp_match | all (default) or any |
sobp_statuses | Array of status keys, such as wc-processing |
sobp_date_from, sobp_date_to | Dates as YYYY-MM-DD |
sobp_total_min, sobp_total_max | Order total |
sobp_customer_type | guest or registered |
sobp_role | Customer role |
sobp_coupon | Coupon code |
An invalid rule inside sobp_rules is ignored. A parameter of the wrong type, such as sobp_match=maybe, is refused with a 400 error by WordPress's schema check.
The orders screen takes the same parameters in its URL, so a link with them opens the list already filtered.
Order queries
wc_get_orders() accepts the rules through the query argument wc_search_orders_by_product_pro:
$rules = WC_Search_Orders_By_Product_Pro::instance()->integrations->marker(
array(
'sobp_rules' => array( array( 'field' => 'product', 'mode' => 'all', 'values' => '12,34' ) ),
),
false // true: match through order item meta instead of the lookup table.
);
$ids = wc_get_orders( array( 'wc_search_orders_by_product_pro' => $rules, 'return' => 'ids', 'limit' => -1 ) );
marker() sanitises the parameters and returns null when they hold no Pro filter.
Hooks
All hooks start with wc_search_orders_by_product_pro_.
| Hook | Type | Use |
|---|---|---|
wc_search_orders_by_product_pro_rule_fields | filter | The fields of the rule builder (product, category, tag, brand, sku, attribute, quantity, item_count), each with a label and its modes. Remove a field, rename it or limit its modes. |
wc_search_orders_by_product_pro_summary_item_meta_limit | filter | Most orders for which the summary reads units and value from order item meta when Analytics data is incomplete. Default 5000. |
wc_search_orders_by_product_pro_query_conditions | filter | SQL conditions of the orders an export or bulk change works on: ( string[] $conditions, string $id_column, string $storage ), where $storage is hpos or posts. |
wc_search_orders_by_product_pro_export_direct_limit | filter | Exports of up to this many orders download straight away; larger ones run in the background. Default 500. |
wc_search_orders_by_product_pro_bulk_batch_size | filter | Orders changed per background batch. Default 50. |
wc_search_orders_by_product_pro_bulk_statuses | filter | Status keys the bulk change offers. Default pending, processing, on-hold, completed, cancelled and failed. Refunded and Draft are always left out. |
wc_search_orders_by_product_pro_licence_product_ids | filter | Product ids of the licence in WPHEKA's licence server, one per licence size. |
wc_search_orders_by_product_pro_licence_api_url | filter | Address of the licence server. |
Stored data
| Data | Where |
|---|---|
| Personal saved views | User option wc_search_orders_by_product_pro_views (stored with the site's table prefix) |
| Shared saved views | Option wc_search_orders_by_product_pro_shared_views |
| Background jobs | One option per job, wc_search_orders_by_product_pro_job_<id>, listed in wc_search_orders_by_product_pro_jobs; removed after a day |
| Export files | uploads/wc-search-orders-by-product-pro/exports/, random names, removed after a day |
| SKU at order time | Order item meta _wc_search_orders_by_product_pro_sku, hidden on the order screen |
| Licence | Option wc_search_orders_by_product_pro_licence |
Scheduled actions use the Action Scheduler group wc-search-orders-by-product-pro. Deactivating Pro removes them. Deleting Pro removes everything above except the SKU on order lines and the notes added by bulk changes, which are part of your order history.