Created
November 26, 2023 14:02
-
-
Save hamidrezayazdani/9e18e85290eb7ac36bbe6699a9c05deb to your computer and use it in GitHub Desktop.
Speedup WooCommerce admin area orders search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* When you have many orders, searching in the WooCommerce admin section will be very slow. | |
* The reason is that WooCommerce looks for the search term in many fields of the order | |
* (such as billing address and shipping address). | |
* With the following code, you can search only the metas you need. | |
* For me, only the first name and last name were important. | |
* Of course, the search will still be done based on the phone number, email and order number, | |
* and there will be no problem in the main function. | |
*/ | |
function ywp_disable_search_in_order_meta( $args ) { | |
return array( | |
'_billing_first_name', | |
'_billing_last_name', | |
); | |
} | |
add_filter( 'woocommerce_shop_order_search_fields', 'ywp_disable_search_in_order_meta' ); | |
// The code goes to your active theme/child-theme's functions.php file | |
// TESTED AND WORKS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment