【问题标题】:Custom order status background button color in Woocommerce 3.3 admin order listWoocommerce 3.3 管理订单列表中的自定义订单状态背景按钮颜色
【发布时间】:2018-08-26 06:37:52
【问题描述】:

在新的 woo 订单屏幕中,旧的颜色状态图标现在消失了,取而代之的是带有彩色背景的大状态按钮。

处理为绿色,已完成为蓝色,已取消为灰色等。

我在 woocommerce 订单中有一个自定义订单状态,称为:进行中。自定义订单状态似乎也只有默认的灰色背景。我想为我的自定义订单状态分配颜色背景。我试图找到一个代码 sn-p 来做到这一点,但没有运气。

【问题讨论】:

    标签: php css wordpress woocommerce orders


    【解决方案1】:

    您可以通过这种方式将 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 文件中。经过测试并且可以工作。

    【讨论】:

    • 完美! -非常感谢!
    • @yatgirl 在这里更新了代码……see my answer in your last question 进行解释……抱歉:)
    • 我想知道如何调整此代码,以便它也可以与 WooCommerce 订单状态管理器的自定义状态一起使用
    猜你喜欢
    • 2021-09-01
    • 2021-02-16
    • 2018-08-04
    • 1970-01-01
    • 2021-02-21
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    相关资源
    最近更新 更多