woocommerce_rest_(post_type)_object_query
Filter the query arguments for a request.
Enables adding extra arguments or setting defaults for a post collection request.
Usage
add_filter( 'woocommerce_rest_(post_type)_object_query', 'wp_kama_woocommerce_rest_post_type_object_query_filter', 10, 2 );
/**
* Function for `woocommerce_rest_(post_type)_object_query` filter-hook.
*
* @param array $args Key value array of query var to query value.
* @param WP_REST_Request $request The request used.
*
* @return array
*/
function wp_kama_woocommerce_rest_post_type_object_query_filter( $args, $request ){
// filter...
return $args;
}
- $args(array)
- Key value array of query var to query value.
- $request(WP_REST_Request)
- The request used.
Where the hook is called
woocommerce_rest_(post_type)_object_query
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php 355
$args = apply_filters( "woocommerce_rest_{$this->post_type}_object_query", $args, $request );
Where the hook is used in WooCommerce
woocommerce/includes/class-wc-brands.php 71
add_filter( 'woocommerce_rest_product_object_query', array( $this, 'rest_api_filter_products_by_brand' ), 10, 2 );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-network-orders-v2-controller.php 141
add_filter( 'woocommerce_rest_orders_prepare_object_query', array( $this, 'network_orders_filter_args' ) );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-network-orders-v2-controller.php 143
remove_filter( 'woocommerce_rest_orders_prepare_object_query', array( $this, 'network_orders_filter_args' ) );