Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WooCommerce Orders search #2554

Merged
merged 22 commits into from
Jan 27, 2022
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a7438f
Fix WooCommerce Orders search
felipeelia Jan 14, 2022
2671642
Add a new ep_woocommerce_shop_order_search_fields filter
felipeelia Jan 14, 2022
a391c89
Shop orders; Conditionally add ID to search field + docs
felipeelia Jan 24, 2022
d0f8530
Shop Orders: tests for searches with numbers
felipeelia Jan 24, 2022
a081893
[Temporary] Log the request and the query on errors
felipeelia Jan 24, 2022
8823b89
Add params to log function
felipeelia Jan 24, 2022
315b8b9
Fix place of logging function
felipeelia Jan 24, 2022
a70bbc3
Use ES's _id instead of ID
felipeelia Jan 24, 2022
a38f322
Revert back to use ID
felipeelia Jan 24, 2022
b74a336
Fix WooCommerce Orders search
felipeelia Jan 14, 2022
0e65c85
Add a new ep_woocommerce_shop_order_search_fields filter
felipeelia Jan 14, 2022
7634e5b
Shop orders; Conditionally add ID to search field + docs
felipeelia Jan 24, 2022
4b56503
Shop Orders: tests for searches with numbers
felipeelia Jan 24, 2022
d33c987
[Temporary] Log the request and the query on errors
felipeelia Jan 24, 2022
d944cac
Add params to log function
felipeelia Jan 24, 2022
c3e11d5
Fix place of logging function
felipeelia Jan 24, 2022
64d70d8
Use ES's _id instead of ID
felipeelia Jan 24, 2022
71caf57
Revert back to use ID
felipeelia Jan 24, 2022
c8b1793
Merge branch 'fix/woocommerce-order-search' of github.com:10up/Elasti…
felipeelia Jan 26, 2022
6e2de08
Adjust query fuzziness when using fields with type `long`
felipeelia Jan 26, 2022
dd2521e
Merge branch '4.x.x' into fix/woocommerce-order-search
felipeelia Jan 26, 2022
80030a2
Remove logging
felipeelia Jan 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Shop orders; Conditionally add ID to search field + docs
  • Loading branch information
felipeelia committed Jan 26, 2022
commit 7634e5be2e3a9dda318192d3f61ea9c185ef3c79
13 changes: 9 additions & 4 deletions includes/classes/Feature/WooCommerce/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,11 @@ public function translate_args( $query ) {

// Search query
if ( 'shop_order' === $post_type ) {
$search_fields = $query->get( 'search_fields', array( 'ID', 'post_title', 'post_content', 'post_excerpt' ) );
$default_search_fields = array( 'post_title', 'post_content', 'post_excerpt' );
if ( is_int( $s ) ) {
$default_search_fields[] = 'ID';
}
$search_fields = $query->get( 'search_fields', $default_search_fields );

$search_fields['meta'] = array_map(
'wc_clean',
Expand Down Expand Up @@ -431,10 +435,11 @@ public function translate_args( $query ) {
*
* @hook ep_woocommerce_shop_order_search_fields
* @since 4.0.0
* @param {array} $fields Shop order fields
* @return {array} New fields
* @param {array} $fields Shop order fields
* @param {WP_Query} $query WP Query
* @return {array} New fields
*/
apply_filters( 'ep_woocommerce_shop_order_search_fields', $search_fields )
apply_filters( 'ep_woocommerce_shop_order_search_fields', $search_fields, $query )
);
} elseif ( 'product' === $post_type && defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
$search_fields = $query->get( 'search_fields', array( 'post_title', 'post_content', 'post_excerpt' ) );
Expand Down