woocommerce_hpos_generate_where_for_search_filter
Filter to support adding a custom order search filter. Provide a WHERE clause for a custom search filter via this filter. This should be used with the woocommerce_hpos_admin_search_filters declare a new custom filter, and optionally also with the woocommerce_hpos_generate_join_for_search_filter if a join is also needed.
Hardcoded filters (products, customers, ID and email) cannot be modified using this filter for consistency.
Usage
add_filter( 'woocommerce_hpos_generate_where_for_search_filter', 'wp_kama_woocommerce_hpos_generate_where_for_search_filter', 10, 4 ); /** * Function for `woocommerce_hpos_generate_where_for_search_filter` filter-hook. * * @param string $where WHERE clause to add to the search query. * @param string $search_term The search term. * @param string $search_filter Name of the search filter. Use this to bail early if this is not the filter you are looking for. * @param OrdersTableQuery $query The order query object. * * @return string */ function wp_kama_woocommerce_hpos_generate_where_for_search_filter( $where, $search_term, $search_filter, $query ){ // filter... return $where; }
- $where(string)
- WHERE clause to add to the search query.
- $search_term(string)
- The search term.
- $search_filter(string)
- Name of the search filter. Use this to bail early if this is not the filter you are looking for.
- $query(OrdersTableQuery)
- The order query object.
Changelog
Since 8.9.0 | Introduced. |
Where the hook is called
woocommerce_hpos_generate_where_for_search_filter
woocommerce/src/Internal/DataStores/Orders/OrdersTableSearchQuery.php 225-231
return apply_filters( 'woocommerce_hpos_generate_where_for_search_filter', '', $this->search_term, $search_filter, $this->query );