Let’s begin with the simple things. But not simple for everyone obviously – let me explain – I’ve seen a tutorial where it was recommended to change the Thank You page title with WordPress the_title hook. It is so weird   WooCommerce has specific hooks for that: woocommerce_endpoint_order-received_title
and woocommerce_thankyou_order_received_text. But what is the difference?

The first hook woocommerce_endpoint_order-received_title allows to change “Order received” text, the second hook woocommerce_thankyou_order_received_text – “Thank you. Your order has been received.”

Let’s do it  All the code from this tutorial you can insert to you current theme functions.php but I recommend to use a child theme or a custom plugin.

add_filter( ‘woocommerce_endpoint_order-received_title’, ‘misha_thank_you_title’ );

function misha_thank_you_title( $old_title ){

     return ‘You\’re awesome!’;

  • Do you see (Line 3) that this hook has the only one argument – $old_title, but what about order details? Well, you can easily get the order id from the key $_GET variable $order_id = wc_get_order_id_by_order_key( $_GET[‘key’] ); and after that get the order object $order = wc_get_order( $order_id ) from the order ID.

add_filter( ‘woocommerce_thankyou_order_received_text’, ‘misha_thank_you_title’, 20, 2 );

function misha_thank_you_title( $thank_you_title, $order ){

     return ‘Oh ‘ . $order->get_billing_first_name() . ‘, thank you so much for your order!’;

}

  • Line 3 – look, here is the $order variable and you know what? It is the order object! It means that we can change the thank you page subtitle dynamically depending on the order details and purchased products.

And here is the result: