如何为admin woocommerce订阅表添加自定义过滤器?

时间:2018-07-28 12:09:54

标签: woocommerce woocommerce-subscriptions

如何在管理面板中为woocommerce订阅表添加自定义过滤器? 因为当我在下面使用此代码时,该表将返回所有帖子

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',
    ) );
}

0 个答案:

没有答案