• Resolved Snake93

    (@bodybuildinggeneration)


    In my functions.php file I have a function that renames order status, it works fine, so order status is renamed correctly. Now I’m trying to add css classes to each order status but I can’t. Can anyone show me the right way to do this ? I appreciate any response, thanks.

    This is the function that renames order status:

    add_filter( 'wc_order_statuses', 'ts_rename_order_status_msg', 20, 1 );
    function ts_rename_order_status_msg( $order_statuses ) {
     $order_statuses['wc-completed']       = _x( 'Acquistato', 'Order status', 'woocommerce' ); 
     $order_statuses['wc-processing']      = _x( 'Processing', 'Order status', 'woocommerce' );
     $order_statuses['wc-on-hold']         = _x( 'In Attesa', 'Order status', 'woocommerce' );
     $order_statuses['wc-pending']         = _x( 'Sospeso', 'Order status', 'woocommerce' );    
     
     return $order_statuses;
    }

    This is what I tried to do:
    $order_statuses['wc-completed'] = _x( '<div class="label success">Acquistato</div>', 'Order status', 'woocommerce' );

    So on the frontend I display everything correctly, but in the backend if I go to woocommerce> settings> status column the html tag is displayed instead of the css effects. So the inserted tag is not read as html but as simple text.

    Here you can get an idea of what I mean: https://i.stack.imgur.com/ZAEnx.png

    can i fix it somehow?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to add css class to order status’ is closed to new replies.