woocommerce_rest_query_var-<var>

Filter the query_vars used in `get_items` for the constructed query.

Description

apply_filters( 'woocommerce_rest_query_var-<var>', (mixed) $prepared_args_var ); 

The dynamic portion(s) of the hook name refer to the query_var key.

Parameters (1)

0. $prepared_args_var (mixed)
$var ] The query_var value.

Usage

To run the hook, copy the example below.
  1. $prepared_args_var = apply_filters( 'woocommerce_rest_query_var-{$var}', $prepared_args_var ); 
  2.  
  3. if ( !empty( $prepared_args_var ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_rest_query_var-<var> callback 
  2. function filter_woocommerce_rest_query_var_var( $prepared_args_var ) { 
  3. // make filter magic happen here... 
  4. return $prepared_args_var
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "woocommerce_rest_query_var-{$var}", 'filter_woocommerce_rest_query_var_var', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "woocommerce_rest_query_var-{$var}", 'filter_woocommerce_rest_query_var_var', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/abstracts/abstract-wc-rest-posts-controller.php  
  1. $query_args[ $var ] = apply_filters( "woocommerce_rest_query_var-{$var}", $prepared_args[ $var ] );