Thursday, September 29, 2022
HomeWordPress Developmentwoocommerce offtopic - Including a column to woocomerce admin order web page...

woocommerce offtopic – Including a column to woocomerce admin order web page that may be sorted


I am attempting so as to add a column with customized meta knowledge to my woocommerce admin order checklist and have the ability to kind them by identify. To this point I’ve discovered a code that provides the columns however they don’t seem to be sortable. Can anybody assist? Thanks!

Code that I discovered:

// ADDING 2 NEW COLUMNS WITH THEIR TITLES (holding "Complete" and "Actions" columns on the finish)
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 20 );
operate custom_shop_order_column($columns)
{
    $reordered_columns = array();

    // Inserting columns to a particular location
    foreach( $columns as $key => $column){
        $reordered_columns[$key] = $column;
        if( $key ==  'order_status' ){
            // Inserting after "Standing" column
            $reordered_columns['my-column1'] = __( 'Razred','theme_domain');
            $reordered_columns['my-column2'] = __( 'Šola','theme_domain');
        }
    }
    return $reordered_columns;
}

// Including customized fields meta knowledge for every new column (instance)
add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 20, 2 );
operate custom_orders_list_column_content( $column, $post_id )
{
    change ( $column )
    {
        case 'my-column1' :
            // Get customized put up meta knowledge
            $my_var_one = get_post_meta( $post_id, 'child_class', true );
            if(!empty($my_var_one))
                echo $my_var_one;

            // Testing (to be eliminated) - Empty worth case
            else
                echo '<small>(<em>no worth</em>)</small>';

            break;

        case 'my-column2' :
            // Get customized put up meta knowledge
            $my_var_two = get_post_meta( $post_id, 'child_school', true );
            if(!empty($my_var_two))
                echo $my_var_two;

            // Testing (to be eliminated) - Empty worth case
            else
                echo '<small>(<em>no worth</em>)</small>';

            break;
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments