Woocommerce 3.3管理员订单列表中的自定义订单状态背景按钮颜色
在新的woo订单屏幕中,旧的颜色状态图标现在消失了,取而代之的是带有彩色背景的大状态按钮.
With the new woo orders screen, the old color status icons are now gone and replaced with a large status button with a colored background.
处理为绿色,已完成为蓝色,已取消为灰色等.
Processing is green, Completed is blue, Cancelled is grey etc.
我在woocommerce订单中有一个自定义订单状态,称为:处理中.自定义订单状态似乎也只有默认的灰色背景.我想为我的自定义订单状态分配颜色背景.为此,我试图找到一个代码段,但是没有运气.
I have a custom order status in woocommerce orders called: In Progress. Custom order statuses seem to also be given just a default grey color background. I would like to assign a color background to my custom order status. I have tried to find a code snippet in order to do this, but have had no luck.
您可以通过以下方式将CSS颜色和背景颜色设置为在管理订单列表中显示的自定义订单状态:
You can set CSS color and background color to your custom order status displayed in admin order list this way:
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文件中.经过测试,可以正常工作.
Code goes in function.php file of your active child theme (or active theme). Tested and works.