Can anyone let me know, how can i add / set filter by company name in woo-commerce order page.
and please share functions or show my error so i can solved it.
i tried it but not working. you help is much appreciated.
add_action( 'restrict_manage_posts', 'admin_shop_order_by_product_type_filter' );
function admin_shop_order_by_product_type_filter(){
global $pagenow, $post_type;
if( 'shop_order' === $post_type && 'edit.php' === $pagenow ) {
$domain = 'woocommerce';
$filter_id = 'filter_billing_company';
$current = isset($_GET[$filter_id])? $_GET[$filter_id] : '';
$query_args = ['fields' => '_billing_company', 'orderby' => 'order'];
echo "<pre>";print_r(get_terms($query_args)); echo "</pre>";
echo '<select name="'.$filter_id.'">
<option value="">' . __('Filter by Company', $domain) . '</option>';
foreach ( get_terms($query_args) as $term_name ) {
printf( '<option value="%s"%s>%s</option>', $term_name,
$term_name === $current ? '" selected="selected"' : '', ucfirst($term_name) );
}
echo '</select>';
}
}
Thanks
