Stats: Add "all" searchby param to Customer report endpoints

Makes it possible to do a partial match search for customers across
name, username, and email, instead of having to choose one of those
fields.

Refs #33383
This commit is contained in:
Corey McKrill 2023-06-06 16:29:49 -07:00
parent 532f3ca3f8
commit d5c0fab66f
No known key found for this signature in database
GPG Key ID: 84BBFE669C4D97B8
3 changed files with 5 additions and 0 deletions

View File

@ -354,6 +354,7 @@ class Controller extends GenericController implements ExportableInterface {
'name',
'username',
'email',
'all',
),
);
$params['name_includes'] = array(

View File

@ -297,6 +297,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
'name',
'username',
'email',
'all',
);
if ( ! empty( $query_args['search'] ) ) {
@ -304,6 +305,8 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
if ( empty( $query_args['searchby'] ) || 'name' === $query_args['searchby'] || ! in_array( $query_args['searchby'], $search_params, true ) ) {
$searchby = "CONCAT_WS( ' ', first_name, last_name )";
} elseif ( 'all' === $query_args['searchby'] ) {
$searchby = "CONCAT_WS( ' ', first_name, last_name, username, email )";
} else {
$searchby = $query_args['searchby'];
}

View File

@ -218,6 +218,7 @@ class Controller extends \WC_REST_Reports_Controller {
'name',
'username',
'email',
'all',
),
);
$params['name_includes'] = array(