php-在Woocommerce管理订单列表中显示具有“全部”自定义状态的订单
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-在Woocommerce管理订单列表中显示具有“全部”自定义状态的订单,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2070字,纯文字阅读大概需要3分钟。
内容图文
我使用此代码创建了一些自定义订单状态
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-在Woocommerce管理订单列表中显示具有“全部”自定义状态的订单全部内容,希望文章能够帮你解决php-在Woocommerce管理订单列表中显示具有“全部”自定义状态的订单所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。