在新的 woo 订单屏幕中,旧的彩色状态图标现已消失,取而代之的是带有彩色背景的大状态按钮。
处理中为绿色,已完成为蓝色,已取消为灰色等。
我在 woocommerce 订单中有一个自定义订单状态,名为:进行中。自定义订单状态似乎也只给出了默认的灰色背景。我想为我的自定义订单状态分配颜色背景。我试图找到一个代码片段来做到这一点,但没有运气。
您可以通过以下方式将 CSS 颜色和背景颜色设置为管理订单列表中显示的自定义订单状态:
add_action('admin_head', 'styling_admin_order_list' );
function styling_admin_order_list() {
global $pagenow, $post;
if( $pagenow != 'edit.php') return; // Exit
if( get_post_type($post->ID) != 'shop_order' ) return; // Exit
// HERE we set your custom status
$order_status = 'Dispatched'; // <==== HERE
?>
<style>
.order-status.status-<?php echo sanitize_title( $order_status ); ?> {
background: #d7f8a7;
color: #0c942b;
}
</style>
<?php
}
代码位于活动子主题(或活动主题)的 function.php 文件中。经过测试并有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)