How to add custom message to thankyou/order receive page in Woocommerce?

Woocommerce’s default order page covers up pretty much everything. However, we often feel the need to add a custom message to the order page.

In this tutorial, We will learn how to add a custom message to an Thank you/ order page. Lets go to orders page to customize it.

So, go to product page and add the product to cart:


Add the Product to Cart and proceed to checkout.


Now, follow the checkout process, fill in all the detail, select appropriate payment option and complete this step by clicking on Place Order link.

After successfully placing order you’ll be directed to thank you page and / or order detail page.

Now, let’s see how the default order page looks like. Following is what the default order detail page looks like:


We want to Add custom message on the above page. Let’s say we want to add categories to which this product belongs to.

Add the following lines of code at the end of your theme’s functions.php file:

function add_notes_to_order($order){
	$categories = array();
    foreach( $order->get_items() as $item_id => $item ) {
    	$pid = $item['product_id'];
        $pcats = wp_get_post_terms( $pid, 'product_cat' );
        foreach( $pcats as $key => $value ){
    echo '<b>This product belongs to following categories: </b>'.implode(' , ',$categories);
add_action( 'woocommerce_order_details_after_order_table', 'add_notes_to_order',10,1 );

You can change the message from the above code. It is located on second last line of Code.

2015-09-03_1239That is it.

Please Post a comment if you have any Questions.

Editorial Staff

ThemeLocation Provides Wordpress & Woocommerce development & Customization services. Have a Project? Contact To discuss

Leave a Reply

Your email address will not be published. Required fields are marked *