Skip to main content

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
ParameterValue
sobp_rulesArray 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_matchall (default) or any
sobp_statusesArray of status keys, such as wc-processing
sobp_date_from, sobp_date_toDates as YYYY-MM-DD
sobp_total_min, sobp_total_maxOrder total
sobp_customer_typeguest or registered
sobp_roleCustomer role
sobp_couponCoupon 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_.

HookTypeUse
wc_search_orders_by_product_pro_rule_fieldsfilterThe 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_limitfilterMost 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_conditionsfilterSQL 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_limitfilterExports 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_sizefilterOrders changed per background batch. Default 50.
wc_search_orders_by_product_pro_bulk_statusesfilterStatus 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_idsfilterProduct ids of the licence in WPHEKA's licence server, one per licence size.
wc_search_orders_by_product_pro_licence_api_urlfilterAddress of the licence server.

Stored data​

DataWhere
Personal saved viewsUser option wc_search_orders_by_product_pro_views (stored with the site's table prefix)
Shared saved viewsOption wc_search_orders_by_product_pro_shared_views
Background jobsOne 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 filesuploads/wc-search-orders-by-product-pro/exports/, random names, removed after a day
SKU at order timeOrder item meta _wc_search_orders_by_product_pro_sku, hidden on the order screen
LicenceOption 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.