My Account

WooCommerce Show Products Ordered In My Account Orders Table

WooCommerce my account view orders showing products column

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

This snippets allows you to add a custom column to the Orders table under My Account which will be populated with products from the order. Implementing this snippet allows your customers see from a top level view which products are part of which order without having to tirelessly drill-down into each order to see which products have been order. By reducing the number of clicks the customer has to make to find out basic information, greatly improves the customer experience as they get the information they are after more quickly.

/**
 * Snippet Name:	WooCommerce Show Products Ordered In My Account Orders Table
 * Snippet Author:	ecommercehints.com
 */

// First, create the new table column between Date and Status columns
add_filter( 'woocommerce_my_account_my_orders_columns', 'ecommercehints_product_column_my_account_orders_table', 10, 1 );
function ecommercehints_product_column_my_account_orders_table( $columns ) {
    $product_column = [];
    foreach ( $columns as $key => $name ) {
        $product_column[ $key ] = $name;
        if ( 'order-date' === $key ) {
            $product_column['order-items'] = __( 'Product', 'woocommerce' );
        }
    }
    return $product_column;
}

// Second, insert the data from the order into the new column
add_action( 'woocommerce_my_account_my_orders_column_order-items', 'ecommercehints_get_product_data', 10, 1 );
function ecommercehints_get_product_data( $order ) {
    $details = array();
    foreach( $order->get_items() as $item ) {
		$product = $item->get_product();
		$product_permalink = get_permalink( $product->get_id() );
        $details[] = '<a href="' . $product_permalink . '">' . $item->get_name() . '<strong class="product-quantity">&nbsp;&times;&nbsp;' . $item->get_quantity() . '</strong>';
	}
    echo count( $details ) > 0 ? implode( '<br>', $details ) : '&ndash;';
}

Snippet Benefits

  • Reduce the number of clicks the customer has to make to view which products are part of which order.
  • Products from the order are shown in a new, custom column meaning the user doesn’t have to ‘View Order’ too see which products have been ordered.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 10% off on your first month with us.

26027
WELCOME OFFER