Added `filter_empty` parameter

This commit is contained in:
kidinov 2023-06-20 12:46:53 +02:00
parent 109b9bfb2e
commit 7f8aa07cdc
1 changed files with 20 additions and 0 deletions

View File

@ -73,6 +73,7 @@ class Controller extends GenericController implements ExportableInterface {
$args['customers'] = $request['customers'];
$args['users'] = $request['users'];
$args['force_cache_refresh'] = $request['force_cache_refresh'];
$args['filter_empty'] = $request['filter_empty'];
$between_params_numeric = array( 'orders_count', 'total_spend', 'avg_order_value' );
$normalized_params_numeric = TimeInterval::normalize_between_params( $request, $between_params_numeric, false );
@ -522,6 +523,25 @@ class Controller extends GenericController implements ExportableInterface {
'type' => 'integer',
),
);
$params['filter_empty'] = array(
'description' => __( 'Filter out results where all passed fields are empty', 'woocommerce' ),
'type' => 'array',
'validate_callback' => 'rest_validate_request_arg',
'items' => array(
'type' => array(
'description' => __( 'Fields that required to be not empty', 'woocommerce' ),
'type' => 'string',
'enum' => array(
'email',
'name',
'country',
'city',
'region',
'postcode',
),
)
),
);
return $params;
}