显示具有“所有"商品的自定义状态的订单在Woocommerce管理订单列表中 [英] Display orders with a custom status for "all" in Woocommerce admin orders list

查看:113
本文介绍了显示具有“所有"商品的自定义状态的订单在Woocommerce管理订单列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have created few custom order status using this code

 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个订单,仅保留中

All is running good except of all orders listing. it shows the correct count all(3) but in the listing you will only see 1 order and it is not displaying all 2 other orders which has been updated into the new custom order status. 1 order is displaying only which is on-hold only

推荐答案

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

To solve the problem, you need to add your custom order in wc_order_statuses filter hook too…

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

At the same time it can be useful to have it displayed in bulk actions dropdown.

完整代码:

// 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文件中.经过测试,可以正常工作.

Code goes in function.php file of your active child theme (or active theme). Tested and works.

这篇关于显示具有“所有"商品的自定义状态的订单在Woocommerce管理订单列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆