I am trying to add a column to the table provided by WooCommerce Analytics -> Orders, and the item name (not product name) of this order is displayed on it.
I added a hook and tried to extract all names of the item in the order (this hook is what I used before, and it's useful at the WooCommerce -> Orders table)
/**
* Adds 'Item Name' column header to 'Orders' page immediately after 'Customer Type' column.
*
* @param string[] $columns
* @return string[] $new_columns
*/
function sv_wc_reps_add_order_item_name_column_header( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'customer_type' === $column_name ) {
$new_columns['order_item_name'] = __( 'Item Name', 'my-textdomain' );
}
}
return $new_columns;
}
add_filter( 'woocommerce_report_orders_export_columns', 'sv_wc_reps_add_order_item_name_column_header', 20 );
/**
* Adds 'Item Name' value into each column
*/
add_action( 'woocommerce_report_orders_prepare_export_item' , 'custom_orders_list_column_content', 20, 2 );
function custom_orders_list_column_content( $column, $post_id ) {
global $the_order, $post;
if ( 'order_item_name' === $column ) {
$products_names = []; // Initializing
// Loop through order items
foreach ( $the_order->get_items() as $item ) {
$product = $item->get_product(); // Get the WC_Product object
$products_names[] = $item->get_name(); // Store in an array
}
// Display
echo '<ul style="list-style: none;"><li>' . implode('</li><li>', $products_names) . '</li></ul>';
}
}
But after I saved my code and refreshed the page, the order report table did not add a new column, and when I clicked to download report, the csv file did not display the new column. I think my code is missing some important parts.

