woocommerce_hpos_pre_query filter-hookWC 8.2.0

Filters the orders array before the query takes place.

Return a non-null value to bypass the HPOS default order queries.

If the query includes limits via the limit, page, or offset arguments, we encourage the found_orders and max_num_pages properties to also be set.

Usage

add_filter( 'woocommerce_hpos_pre_query', 'wp_kama_woocommerce_hpos_pre_query_filter', 10, 3 );

/**
 * Function for `woocommerce_hpos_pre_query` filter-hook.
 * 
 * @param array|null       $order_data An array of order data.
 * @param OrdersTableQuery $query      The OrdersTableQuery instance.
 * @param string           $sql        The OrdersTableQuery instance.
 *
 * @return array|null
 */
function wp_kama_woocommerce_hpos_pre_query_filter( $order_data, $query, $sql ){

	// filter...
	return $order_data;
}
$order_data(array|null)

An array of order data.

  • orders(int[])
    Return an array of order IDs data to short-circuit the HPOS query, or null to allow HPOS to run its normal query.

  • found_orders(int)
    The number of orders found.

  • max_num_pages(int)
    The number of pages.
$query(OrdersTableQuery)
The OrdersTableQuery instance.
$sql(string)
The OrdersTableQuery instance.

Changelog

Since 8.2.0 Introduced.

Where the hook is called

OrdersTableQuery::maybe_override_query()
woocommerce_hpos_pre_query
woocommerce/src/Internal/DataStores/Orders/OrdersTableQuery.php 233
$pre_query = apply_filters( 'woocommerce_hpos_pre_query', null, $this, $this->sql );

Where the hook is used in WooCommerce

Usage not found.