If you’re running a WooCommerce store, you know how important product reviews are for building trust and boosting sales. But as your product catalog grows, it can become hard for customers to keep track of which purchases still need reviews.
That’s where a Purchase History tab comes in handy. Imagine offering your customers a simple way to see all their previous purchases, with a clear indicator of which items they haven’t reviewed yet.
In this tutorial, we’ll show you how to create a custom Purchase History tab within the My Account page. This tab will list purchased products, the date of purchase, and provide a quick “Review” link if the product hasn’t been reviewed yet.
Itβs a small feature that can make a big impact on your storeβs reviews and engagement. Keep reading to find the code snippet that will make it happen!
PHP Snippet 1 of 2: Custom “Purchase History” Tab @ WooCommerce My Account
First of all, let’s create a custom tab. I’m using my “Add a custom My Account tab” tutorial for this.
Note: resave / refresh your permalinks once you use the code below, otherwise the tab will give you 404 error.
/**
* @snippet Purchase History Tab | WooCommerce My Account
* @tutorial https://businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_action( 'init', 'bbloomer_add_purchase_history_endpoint' );
function bbloomer_add_purchase_history_endpoint() {
add_rewrite_endpoint( 'purchase-history', EP_ROOT | EP_PAGES );
}
add_filter( 'query_vars', 'bbloomer_purchase_history_query_vars', 0 );
function bbloomer_purchase_history_query_vars( $vars ) {
$vars[] = 'purchase-history';
return $vars;
}
add_filter( 'woocommerce_get_query_vars', 'bbloomer_add_wc_query_vars' );
function bbloomer_add_wc_query_vars( $vars ) {
$vars['purchase-history'] = 'purchase-history';
return $vars;
}
Also, let’s give it a page title:
add_filter( 'woocommerce_endpoint_purchase-history_title', 'bbloomer_purchase_history_title' );
function bbloomer_purchase_history_title( $title ) {
return 'Purchase History';
}
Here’s the final result:

PHP Snippet 2 of 2: “Purchase History” Tab Content
Now let’s populate the tab with the list of purchased items by the current user. Each item will get a series of custom actions, and one of these may be the “Leave a Review” button in case they haven’t left a review yet!
/**
* @snippet Purchase History Tab Content | WooCommerce My Account
* @tutorial https://businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_action( 'woocommerce_account_purchase-history_endpoint', 'bbloomer_display_purchase_history' );
function bbloomer_display_purchase_history() {
$customer_orders = wc_get_orders( array(
'customer_id' => get_current_user_id(),
'status' => wc_get_is_paid_statuses(),
'limit' => -1,
));
$customer = new WC_Customer( get_current_user_id() );
$reviewed_products = [];
$comments = get_comments( array(
'author_email' => $customer->get_billing_email(),
'type' => 'review',
'status' => 'approve',
));
foreach ( $comments as $comment ) {
$reviewed_products[] = $comment->comment_post_ID;
}
if ( $customer_orders ) {
echo '<table class="woocommerce-table shop_table shop_table_responsive">';
echo '<thead><tr><th>Product</th><th>Date</th><th>Actions</th></tr></thead><tbody>';
foreach ( $customer_orders as $order ) {
foreach ( $order->get_items() as $item_id => $item ) {
$product = $item->get_product();
echo '<tr>';
echo '<td><a href="' . esc_url( $product->get_permalink() ) . '">' . esc_html( $item->get_name() ) . '</a></td>';
echo '<td>' . esc_html( wc_format_datetime( $order->get_date_created() ) ) . '</td>';
echo '<td>';
if ( ! in_array( $product->get_id(), $reviewed_products ) ) {
echo '<a class="button alt" href="' . esc_url( get_permalink( $product->get_id() ) . '#tab-reviews' ) . '">' . esc_html__( 'Add a review', 'woocommerce' ) . '</a> ';
}
echo '</td>';
echo '</tr>';
}
}
echo '</tbody></table>';
} else {
echo '<p>No purchases found.</p>';
}
}
And this is how it will look:

In case the current user already reviewed a given product, the button won’t show. You can of course add other custom actions, such as “Share with a friend”, “Order again”, etc.
Hello ,
I would like to add a thumbnail of the product to the table, but I am not really familiar with php to make this happen. I added the following line, but I can’t get the image to appear:
.
Jan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
This would be amazing if the leave a review buttons could be added to the existing downloads tab?!
Sure, that’s possible as well
That would be amazing as in using this code there’s no tab thats added to my Account page π
Manually going to mysite/my-account/purchase-history/ return a no purchases found in my tests π
I believe I have this coded and working now. The tutorial will go live on March 4 at 2:09 pm Italy time: https://www.businessbloomer.com/woocommerce-add-leave-a-review-column-to-downloads-table/
Hello
As for “Darren Cowley”, it doesn’t work for me and I have the same result. Maybe something is wrong with the code. I don’t have this new tab and its content.
Note: I use WPCode pro to insert code snippets into my websites (back-end and front-end).
Did you refresh permalinks?