Merge pull request #25314 from woocommerce/fix/24746
Removed the lowercase conversion of product search terms
This commit is contained in:
commit
2668bf6025
|
@ -880,7 +880,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
}
|
||||
|
||||
return $wpdb->get_results(
|
||||
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
|
||||
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
"
|
||||
SELECT posts.ID as id, posts.post_parent as parent_id
|
||||
FROM {$wpdb->posts} AS posts
|
||||
|
@ -898,7 +898,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
)
|
||||
GROUP BY posts.ID
|
||||
"
|
||||
// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared
|
||||
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1553,7 +1553,6 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
$type_where = '';
|
||||
$status_where = '';
|
||||
$limit_query = '';
|
||||
$term = wc_strtolower( $term );
|
||||
|
||||
/**
|
||||
* Hook woocommerce_search_products_post_statuses.
|
||||
|
@ -1567,8 +1566,8 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
);
|
||||
|
||||
// See if search term contains OR keywords.
|
||||
if ( strstr( $term, ' or ' ) ) {
|
||||
$term_groups = explode( ' or ', $term );
|
||||
if ( stristr( $term, ' or ' ) ) {
|
||||
$term_groups = preg_split( '/\s+or\s+/i', $term );
|
||||
} else {
|
||||
$term_groups = array( $term );
|
||||
}
|
||||
|
|
|
@ -797,6 +797,12 @@ class WC_Tests_Product_Data_Store extends WC_Unit_Test_Case {
|
|||
$this->assertContains( $product3->get_id(), $results );
|
||||
$this->assertContains( $product4->get_id(), $results );
|
||||
|
||||
$results = $data_store->search_products( 'blue-widget-1 OR green-widget', '', true, true );
|
||||
$this->assertContains( $product->get_id(), $results );
|
||||
$this->assertNotContains( $product2->get_id(), $results );
|
||||
$this->assertContains( $product3->get_id(), $results );
|
||||
$this->assertContains( $product4->get_id(), $results );
|
||||
|
||||
$results = $data_store->search_products( '"green widget"', '', true, true );
|
||||
$this->assertNotContains( $product->get_id(), $results );
|
||||
$this->assertNotContains( $product2->get_id(), $results );
|
||||
|
|
Loading…
Reference in New Issue