Search code examples
phpwordpresswoocommercecustom-fieldsorders

Add a custom field in WooCommerce admin order list "Order" existing column


I am trying to add mycustomfield21 (added to checkout with woo checkout manager) on bulk order details on WooCommerce dashboard. Here is a screenshot to show what I need:

enter image description here

Edited question:

I already inserted two fields, which are first name (myfield21) and surname (myfield22). How can I display a white space between them? Because it shows like "first namesurname".


Solution

  • Update - Nov. 2018 - Added compatibility with Woocommerce version 3.3+

    This is possible hooking a custom function in manage_shop_order_posts_custom_column action hook. Below I am adding the billing phone to the existing Order ("Pedido") column data:

    add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 10, 2 );
    function custom_orders_list_column_content( $column, $post_id ) {
        if ( $column == 'order_title' || $column == 'order_number'  )
        {
            // The billing phone for example (to be repaced by your custom field meta_key)
            $custom_field_value = get_post_meta( $post_id, '_billing_phone', true );
            if( ! empty( $custom_field_value ) )
                echo $custom_field_value;
        }
    }
    

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