Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom order status background button color in Woocommerce 3.3 admin order list

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.

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.

like image 562
yatgirl Avatar asked Mar 06 '23 15:03

yatgirl


1 Answers

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
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

like image 101
LoicTheAztec Avatar answered Apr 07 '23 01:04

LoicTheAztec