php-在Woocommerce管理订单列表中显示具有“全部”自定义状态的订单

我使用此代码创建了一些自定义订单状态

 register_post_status( 'wc-arrival-shipment', array(
        'label'                     => 'Shipped but not paid',
        'public'                    => false,
        'show_in_admin_status_list' => true,
        'show_in_admin_all_list'    => true,
        'exclude_from_search'       => false,
        'label_count'               => _n_noop( 'Shipped but not paid<span class="count">(%s)</span>', 'Shipped but not paid <span class="count">(%s)</span>' )
    ) );

除所有订单清单外,其他一切运行良好.它会显示正确的计数all(3),但是在清单中您只会看到1个订单,并且不会显示所有其他2个已更新为新的自定义订单状态的订单.仅显示1个订单,仅保留

解决方法:

要解决该问题,您还需要在wc_order_statuses过滤器挂钩中添加自定义订单…

同时,将其显示在批量操作下拉菜单中可能很有用.

完整的代码:

// Add custom status to order list
add_action( 'init', 'register_custom_post_status', 10 );
function register_custom_post_status() {
    register_post_status( 'wc-arrival-shipment', array(
        'label'                     => _x( 'Shipped but not paid', 'Order status', 'woocommerce' ),
        'public'                    => false,
        'exclude_from_search'       => false,
        'show_in_admin_status_list' => true,
        'show_in_admin_all_list'    => true,
        'label_count'               => _n_noop( 'Shipped but not paid<span class="count">(%s)</span>', 'Shipped but not paid <span class="count">(%s)</span>' )
    ) );
}

// Add custom status to order edit page drop down (and displaying orders with this custom status in the list)
add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' );
function custom_wc_order_statuses( $order_statuses ) {
    $order_statuses['wc-arrival-shipment'] = _x( 'Shipped but not paid', 'Order status', 'woocommerce' );
    return $order_statuses;
}

// Adding custom status  to admin order list bulk actions dropdown
add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 20, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
    $actions['mark_arrival-shipment'] = __( 'Mark Shipped but not paid', 'woocommerce' );
    return $actions;
}

代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试和工作.

上一篇:php-从产品ID获取所有订单ID


下一篇:php-在Woocommerce 3中通过ajax提交并在结帐时创建订单