Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter evertech

    (@evertech)

    Thank Rodrigo, that did it!
    In case anyone needs to did something similar, here’s the code I used:

    add_filter('post_class', 'set_row_post_class', 10,3);
    function set_row_post_class($classes, $class, $post_id){
        
        // Make sure you're in the admin panel
        if (!is_admin()) {  
            return $classes;
        }
        
        // limit action to product table
        $screen = get_current_screen(); 
        if ('product' != $screen->post_type && 'edit' != $screen->base) {
            return $classes;
        }
        
        // Get stock status of the product 
        $stock = get_post_meta( $post_id, '_stock_status', true );
        
        // Add a class to the <tr> with the stock status
        $classes[] = "stock-status-".$stock;
     
        // Return the array with the classes
        return $classes;
    }
    

    Cheers
    Roberto

Viewing 1 replies (of 1 total)