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?
2
Answers
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:
Hello How can I add more search fields in this function.