Q:

woocommerce - Display Products in View orders page

I'm working on displaying the order products in the View Orders page in the customer account page like this

Can we do this?

A:

Add this to your theme's 'functions.php'.
function add_products_my_account_orders_column( $columns ) {
    $new_columns = array();
    foreach ( $columns as $key => $name ) {
        $new_columns[ $key ] = $name;

        // add products after order total column
        if ( 'order-total' === $key ) {
            $new_columns['order-products'] = __( 'Products', 'textdomain' );
        }
    }
    return $new_columns;
}
add_filter( 'woocommerce_my_account_my_orders_columns', 'add_products_my_account_orders_column' );

function add_products_data_my_account_orders_column( $order ) {
    //loop through products of the order
    foreach( $order->get_items() as $item_id => $item ) {
        $product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );

        $is_visible        = $product && $product->is_visible();
        $product_permalink = apply_filters( 'woocommerce_order_item_permalink', $is_visible ? $product->get_permalink( $item ) : '', $item, $order );

        echo apply_filters( 'woocommerce_order_item_name', $product_permalink ? sprintf( '<p><a href="%s">%s</a>', $product_permalink, $item['name'] ) : $item['name'], $item, $is_visible );
        echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '&times; %s', $item['qty'] ) . '</strong></p>', $item );
    }
}
add_action( 'woocommerce_my_account_my_orders_column_order-products', 'add_products_data_my_account_orders_column' );

