WooCommerce comes with a few basic pages that you need in order for the plugin to work. One of them is the checkout page. The checkout page is the page where your customers can fill in their details and select a payment method to complete their order. Since WooCommerce 2.1 the page the user is redirected to after the payment is complete is also the checkout page but with a different endpoint. Although the content changes per endpoint, the page title stays the same. So can you change the page title based on endpoints?
What are endpoints
Before WooCommerce version 2.1 these endpoints where separate pages with their own shortcodes. The ‘thank you’ endpoint now, was the
[woocommerce_thankyou] shortcode back then. The reason WooCommerce got rid of all these separate pages and shortcodes is because it makes the installation of WooCommerce a lot less prone to user errors. If you forgot or deleted your ‘thank you’ page your customer would get a 404 after they completed the checkout process. As you can imagine, not a good customer experience.
Changing the ‘thank you’ endpoint title
I’m a supporter of the endpoint solution but there’s one thing I don’t like about it. My customers would see ‘Checkout’ as the page title after they completed their payment. This is the page where I want to thank them for their purchase and not confuse them with the feeling they’re still in the checkout process. Luckily it’s quite easy to change the title of the checkout page just for the thank you endpoint. Below snippet can be placed in your theme’s
You can replace the “Thank you for your order!” with anything you like.
Personalizing the thank you page title
For one of my shops I wanted to make the checkout process a more personal experience. One of the things I did was personalizing the ‘thank you’ endpoint title. It’s the first thing that customers see when they completed their order so I wanted to greet them by their first name. Below snippet will fetch the first name of the customer that just completed their order and replace the
%s with their first name. Code snippet below will result in for example: Thank you, Barry!
You can change the title in whatever you want, as long as you place a
%s in it. A small example of a different title:
$title = sprintf( "%s, you are the best!", esc_html( $order->billing_first_name ) );
This will for example result in: John, you are the best!
I hope this helped you in changing your thank you page title. Are you missing something? Found a problem or improvement? Be sure to let me know by leaving a comment!