From ca13468db5a68227d1e23cc417e6f32e0c93dd38 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 18 Mar 2022 09:32:17 -0300 Subject: [PATCH] WC Orders: properly add ID to fields when searching for digits --- includes/classes/Feature/WooCommerce/WooCommerce.php | 2 +- tests/php/features/TestWooCommerce.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/classes/Feature/WooCommerce/WooCommerce.php b/includes/classes/Feature/WooCommerce/WooCommerce.php index d02318d91a..91ffce7148 100644 --- a/includes/classes/Feature/WooCommerce/WooCommerce.php +++ b/includes/classes/Feature/WooCommerce/WooCommerce.php @@ -392,7 +392,7 @@ public function translate_args( $query ) { // Search query if ( 'shop_order' === $post_type ) { $default_search_fields = array( 'post_title', 'post_content', 'post_excerpt' ); - if ( is_int( $s ) ) { + if ( ctype_digit( $s ) ) { $default_search_fields[] = 'ID'; } $search_fields = $query->get( 'search_fields', $default_search_fields ); diff --git a/tests/php/features/TestWooCommerce.php b/tests/php/features/TestWooCommerce.php index c943e8f69b..35c8974b66 100644 --- a/tests/php/features/TestWooCommerce.php +++ b/tests/php/features/TestWooCommerce.php @@ -172,7 +172,7 @@ public function testSearchShopOrderById() { ElasticPress\Elasticsearch::factory()->refresh_indices(); $args = array( - 's' => $shop_order_id, + 's' => (string) $shop_order_id, 'post_type' => 'shop_order', ); @@ -215,7 +215,7 @@ public function testSearchShopOrderByMetaFieldAndId() { ElasticPress\Elasticsearch::factory()->refresh_indices(); $args = array( - 's' => $shop_order_id_1, + 's' => (string) $shop_order_id_1, 'post_type' => 'shop_order', );