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:
parent
532f3ca3f8
commit
d5c0fab66f
|
@ -354,6 +354,7 @@ class Controller extends GenericController implements ExportableInterface {
|
|||
'name',
|
||||
'username',
|
||||
'email',
|
||||
'all',
|
||||
),
|
||||
);
|
||||
$params['name_includes'] = array(
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -218,6 +218,7 @@ class Controller extends \WC_REST_Reports_Controller {
|
|||
'name',
|
||||
'username',
|
||||
'email',
|
||||
'all',
|
||||
),
|
||||
);
|
||||
$params['name_includes'] = array(
|
||||
|
|
Loading…
Reference in New Issue