【问题标题】:Woocommerce not list orders all orders, why?Woocommerce 没有列出所有订单,为什么?
【发布时间】:2019-03-03 12:05:36
【问题描述】:
我的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
【问题讨论】:
标签:
wordpress
woocommerce
【解决方案1】:
创建新的订单状态。示例:
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' );