add_filter( 'manage_woocommerce_page_wc-orders_columns', 'add_wc_order_list_custom_column' );
function add_wc_order_list_custom_column( $columns ) {
$reordered_columns = array();
// Inserting columns to a specific location
foreach( $columns as $key => $column){
$reordered_columns[$key] = $column;
if( $key === 'order_status' ){
// Inserting after "Status" column
$reordered_columns['my-column1'] = __( 'Title1','theme_domain');
$reordered_columns['my-column2'] = __( 'Title2','theme_domain');
}
}
return $reordered_columns;
}
add_action('manage_woocommerce_page_wc-orders_custom_column', 'display_wc_order_list_custom_column_content', 10, 2);
function display_wc_order_list_custom_column_content( $column, $order ){
switch ( $column )
{
case 'my-column1' :
// Get custom order metadata
$value = $order->get_meta('_the_meta_key1');
if ( ! empty($value) ) {
echo $value;
}
// For testing (to be removed) - Empty value case
else {
echo '<small>(<em>no value</em>)</small>';
}
break;
case 'my-column2' :
// Get custom order metadata
$value = $order->get_meta('_the_meta_key2');
if ( ! empty($value) ) {
echo $value;
}
// For testing (to be removed) - Empty value case
else {
echo '<small>(<em>no value</em>)</small>';
}
break;
}
}