Wordpress 如何在订单列表中显示缺货状态

Wordpress 如何在订单列表中显示缺货状态,wordpress,woocommerce,Wordpress,Woocommerce,我们在WooCommerce中有很多缺货订单,我们希望能够对订单表中的所有缺货订单进行排序 目前,我们正在使用以下状态筛选订单:等待发货、退款、取消、完成、处理 请参阅 我在网上搜索了一下,我只发现创建一个单独的菜单链接仅限lisitng backorders 我是否可以在functions.php中添加一个过滤器来完成这项工作?我不想仅仅为此安装插件 现在我只能使用下面的代码添加一个定制的缺货状态,第二步是在有缺货产品时触发状态 /** * Register new status * T

我们在WooCommerce中有很多缺货订单,我们希望能够对订单表中的所有缺货订单进行排序

目前,我们正在使用以下状态筛选订单:等待发货、退款、取消、完成、处理

请参阅

我在网上搜索了一下,我只发现创建一个单独的菜单链接仅限lisitng backorders

我是否可以在functions.php中添加一个过滤器来完成这项工作?我不想仅仅为此安装插件

现在我只能使用下面的代码添加一个定制的缺货状态,第二步是在有缺货产品时触发状态

/** 
 * Register new status
 * Tutorial: http://www.sellwithwp.com/woocommerce-custom-order-status-2/
**/
function register_backorders_order_status() {
    register_post_status( 'wc-backorders', array(
        'label'                     => 'Backorders',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'backorders <span class="count">(%s)</span>', 'Awaiting shipment <span class="count">(%s)</span>' )
    ) );
}
add_action( 'init', 'register_backorders_order_status' );
// Add to list of WC Order statuses
function add_backorders_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-backorders'] = 'Backorders';
        }
    }
    return $new_order_statuses;
}
add_filter( 'wc_order_statuses', 'add_backorders_to_order_statuses' );
/**
*注册新身份
*教程:http://www.sellwithwp.com/woocommerce-custom-order-status-2/
**/
功能寄存器\缺货订单\订单状态(){
注册后状态('wc延期订单',数组(
“标签”=>“延期交货单”,
“public”=>正确,
“从搜索中排除”=>false,
“在\u管理\u所有\u列表中显示\u”=>true,
“在管理状态列表中显示”=>true,
“标签计数”=>“缺货”(“缺货(%s)”,“等待装运(%s)”)
) );
}
添加操作('init','register\u backorders\u order\u status');
//添加到WC订单状态列表
功能将缺货订单添加到订单状态($order\U STATUS){
$new_order_status=array();
//处理后添加新订单状态
foreach($key=>$status的订单状态){
$new_order_status[$key]=$status;
if('wc processing'==$key){
$new_order_status['wc-backorders']='backorders';
}
}
返回$new\u order\u状态;
}
添加过滤器('wc_订单状态','add_backorders_to_order_Status');

\n\u noop('backorders(%s)','waiting shipping(%s))
您使用了backorders(单数)和waiting shipping(复数)?是延期交货还是等待装运?这是过期订单