Woocommerce 3.3 管理订单列表中的自定义订单状态背景按钮颜色 [英] Custom order status background button color in Woocommerce 3.3 admin order list

查看:38
本文介绍了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.

这篇关于Woocommerce 3.3 管理订单列表中的自定义订单状态背景按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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