在新的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文件中。经过测试和工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句