How to add custom metakey to shop_order page's searching function?
My project is a eShop with POS system,The POS is powered by YITH POS. Work with YITH POS its will generate a metakey in wp_postmeta call '_yith_pos_store' to linking the store name. For make it easier to management , I'm planning to make a custom column to display the Store name in woocommerce shop_order page and make its searchable in the search field.The custom column parts is already done but search parts I had tried many ways cannot make it happen, below is my code everyone know how to make it? many thanks!
add_filter( 'manage_edit-shop_order_columns', 'wc_order_pickup_column' );
function wc_order_pickup_column( $columns ) {
$columns['shop_address'] = 'Shop';
return $columns;
}
add_action( 'manage_shop_order_posts_custom_column' , 'custom_shop_order_column_order_pickup', 10, 2 );
function custom_shop_order_column_order_pickup( $column, $post_id ) {
switch ( $column ) {
case 'shop_address' :
$order = get_the_ID();
$shop = get_post_meta($order, '_yith_pos_store', true);
echo esc_html( get_post_meta( $shop, '_name', true ) );
break;
}
}
add_filter( 'woocommerce_shop_order_search_fields', 'order_pickup_search_fields', 10, 1 );
function order_pickup_search_fields( $meta_keys ){
$meta_keys[] = '_name';
return $meta_keys;
}
Topic woocommerce-offtopic post-meta functions e-commerce wp-admin Wordpress
Category Web