'Show product categories in a new column on WooCommerce "My account" orders table

I want to add a custom column, to display the product categories on the orders history table in wooCommerce

I found how to add a custom column but I can't seem to display the taxonomy's product linked to the order in this column.

For this example, I had just 1 product, but if I can display more than one tax, it will be better.

This is what I found (from : skyverge blog) to add a new column:

/**
 * Adds a new column to the "My Orders" table in the account.
 *
 * @param string[] $columns the columns in the orders table
 * @return string[] updated columns
 */
function sv_wc_add_my_account_orders_column( $columns ) {

    $new_columns = array();

    foreach ( $columns as $key => $name ) {

        $new_columns[ $key ] = $name;

        // add ship-to after order status column
        if ( 'order-number' === $key ) {
            $new_columns['order-ship-to'] = __( 'Catégorie', 'textdomain' );
        }
    }

    return $new_columns;
}
add_filter( 'woocommerce_my_account_my_orders_columns', 'sv_wc_add_my_account_orders_column' );

Any pointers are welcome



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source