Woocommerce没有列出所有订单,为什么?

时间:2018-09-27 14:23:39

标签: wordpress woocommerce

我的woocommerce没有列出状态为'wc-expired'的订单。我尝试添加“ wc_order_statuses”过滤器,但仍然无法正常工作。

add_filter('wc_order_statuses', function ($order_statuses){
    $order_statuses['wc-expired'] = _x( 'Expired', 'Order status', 'woocommerce' );
    return $order_statuses;
});

Row in Table wp_posts The Orders List in Admin

1 个答案:

答案 0 :(得分:0)

创建新的订单状态。样本:

    function register_expired_order_status() {
    register_post_status( 'wc-expired', array(
        'label'                     => 'Expired',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Expired <span class="count">(%s)</span>', 'Expired <span class="count">(%s)</span>' )
    ) );
}
add_action( 'init', 'register_expired_order_status' );

function add_expired_to_order_statuses( $order_statuses ) {
    $new_order_statuses = array();
    // add new order status after processing
    foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-processing' === $key ) {
            $new_order_statuses['wc-expired'] = 'Expired';
        }
    }
    return $new_order_statuses;
}
add_filter( 'wc_order_statuses', 'add_expired_to_order_statuses' );