Woocommerce_shop_order_search_fields search order by meta field not working HPOS
Woocommerce_shop_order_search_fields search order by meta field not working HPOS
Before switching to HPOS we had the following code in our functions.php to make it possible to search by a meta field in the woocommerce admin -> orders section.
function custom_woocommerce_shop_order_search_fields( $search_fields ) {
$search_fields[] = 'tracking_number';
return $search_fields;
}
add_filter( 'woocommerce_shop_order_search_fields', 'custom_woocommerce_shop_order_search_fields' );
The meta data inside the order is "tracking_number".
After switching to HPOS this doesn't seem to work anymore. I can't seem to find what has changed and why it isn't working anymore. What is the correct way to do this with HPOS?
According to provided code, to get "order search by meta field functionality" working, when woocommerce High-Performance Order Storage (HPOS) is enabled, the filter "woocommerce_shop_order_search_fields" can be replaced by filter "woocommerce_order_table_search_query_meta_keys". The updated code is as follows:
function custom_woocommerce_shop_order_search_fields( $search_fields ) {
$search_fields[] = 'tracking_number';
return $search_fields;
}
add_filter( 'woocommerce_order_table_search_query_meta_keys', 'custom_woocommerce_shop_order_search_fields' );
January 7, 2024
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand
January 7, 2024