Merge pull request #18532 from woocommerce/fix/18527-numeric-username-lookup

Ajax customer search to cater for numeric usernames
This commit is contained in:
Mike Jolley 2018-01-19 10:36:26 +00:00 committed by GitHub
commit ff7716509e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -1426,17 +1426,19 @@ class WC_AJAX {
wp_die();
}
$ids = array();
// Search by ID.
if ( is_numeric( $term ) ) {
$customer = new WC_Customer( intval( $term ) );
// Customer does not exists.
if ( 0 === $customer->get_id() ) {
wp_die();
if ( 0 !== $customer->get_id() ) {
$ids = array( $customer->get_id() );
}
}
$ids = array( $customer->get_id() );
} else {
// Usernames can be numeric so we first check that no users was found by ID before searching for numeric username, this prevents performance issues with ID lookups.
if ( empty( $ids ) ) {
$data_store = WC_Data_Store::load( 'customer' );
// If search is smaller than 3 characters, limit result set to avoid