This repository was archived by the owner on Jun 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -582,9 +582,9 @@ public function search_orders( $term ) {
582582 $ wpdb ->prepare ( "
583583 SELECT order_id
584584 FROM {$ wpdb ->prefix }woocommerce_order_items as order_items
585- WHERE order_item_name LIKE '%%%s%%'
585+ WHERE order_item_name LIKE %s
586586 " ,
587- $ term
587+ ' % ' . $ wpdb -> esc_like ( $ term ) . ' % '
588588 )
589589 )
590590 ) );
Original file line number Diff line number Diff line change @@ -141,6 +141,21 @@ public function test_search_orders_checks_table_for_product_item_matches() {
141141 );
142142 }
143143
144+ public function test_search_orders_checks_table_for_product_item_matches_with_like_comparison () {
145+ $ product = $ this ->factory ()->product ->create_and_get ( array (
146+ 'post_title ' => 'foo bar baz ' ,
147+ ) );
148+ $ order = $ this ->factory ()->order ->create_and_get ();
149+ $ order ->add_product ( $ product );
150+ $ order ->save ();
151+
152+ $ this ->assertEquals (
153+ array ( $ order ->get_id () ),
154+ ( new WC_Order_Data_Store_Custom_Table () )->search_orders ( 'bar ' ),
155+ 'Product items should be searched using a LIKE comparison and wildcards. '
156+ );
157+ }
158+
144159 /**
145160 * @dataProvider order_type_provider()
146161 */
You can’t perform that action at this time.
0 commit comments