• hey!

    i know how to add custom field to the product page using this plugin – quite simple. But HOW can i add passed value to be displayed in the ORDERS subpage in the backend? when i will go deeply to the order, i can see the data, yet i would like to see it as additional column in orders lists.

    https://wordpress.org/plugins/wc-fields-factory/

Viewing 1 replies (of 1 total)
  • Plugin Author Saravana Kumar K

    (@mycholan)

    Hi, If I understand correctly, you wanted to display custom fields values to Order Archive Page itself right.?

    You can do some thing like this

    add_filter( 'manage_edit-shop_order_columns', 'my_custom_column_handler' );
    function my_custom_column_handler( $columns ){
    	$new_columns = ( is_array( $columns ) ) ? $columns : array();
    	unset( $new_columns['order_actions'] );
    	$new_columns['custom_column'] = 'CUstom Column';
    	$new_columns['order_actions'] = $columns['order_actions'];
    	return $new_columns;
    }
    
    add_action( 'manage_shop_order_posts_custom_column', 'my_custom_column_value_handler', 2 );
    function my_custom_column_value_handler( $column ){
    	global $post;
    
    	if( $column == "custom_column" ) {
    		// Loop through your order line items & display whatever custom fields you want
    		// using wc_get_order_item_meta( $item_id, $key );
    	}
    }
Viewing 1 replies (of 1 total)

The topic ‘Displaying custom fields in the orders’ is closed to new replies.