2

How could I add custom filters for woocommerce subscriptions table in the admin panel? Because when I use this code below, the table returns with all posts

add_filter( 'request', 'subs_filter_retry_count', 999 );
function subs_filter_retry_count( $vars ){
    global $typenow;

    if ( 'shop_subscription' === $typenow ) {

    // Filter the orders by the posted customer.
    if ( isset( $_GET['_retry_count_filter'] ) && $_GET['_retry_count_filter'] > 0 ) {
        $vars['meta_query'][] = array(
            'key'   => '_customer_user',
            'value' => (int) $_GET['_retry_count_filter'],
            'compare' => '=', 
       );
       }
    }
    return $vars;
 }

 add_action('restrict_manage_posts', 'test_test_function');
 function test_test_function(){
global $typenow;

if ( 'shop_subscription' !== $typenow ) {
    return;
}
woocommerce_wp_text_input( array(
    'id'          => '_retry_count_filter',
    'placeholder' => 'Retry count filter',
    'label' => 'Retry count filter',
    ) );
}
Darren
  • 1,682
  • 1
  • 15
  • 33

0 Answers0