Search the site:

Home Blog How to Customize the WooCommerce Thank You Page

How to Customize the WooCommerce Thank You Page

We know that you understand how important it is to be thankful to your customers. You can have a great product or service to sell, but if you please them with nice customized message that they will see after the purchase was done, more likely that they will become repeat customers.

Happy clients are always up for recommending your product or service and thus can serve as the source of promotion – really working and the most reliable one! The importance of an appealing Thank You page is hard to overestimate.

Actually, WooCommerce does this on your behalf. It redirects you to a simple Thank You page (or “Order received” page how is it called sometimes).

Customize WooCommerce Thank You page - WooCommerce - Thank You Page

This is good, but you might want to change this to make it more attractive & appealing.

You can customize the Thank You page to do many things such as introduce after sales service, launch a new promotion, give a discount on the next purchase, etc.

There are different ways to customize the WooCommerce Thank You page:

  • Using free or paid plugins
  • By creating a redirect
  • By using filters
  • By overwriting template files

We will look at each of these methods below.

1. Customize the WooCommerce Thank You page with plugins

In the first case, you will possible have a straightforward plugin with the full range of functionality. Some of the free plugins available on the repository are:

  1. WooCommerce Thank You Page – NextMove Lite – This plugin allows you to build custom Thank You pages to pull more profits. It gives you access to a suite of plug & play components such as Dynamic coupons, Videos , HTML, Image & text blocks, recommended products, social share and more.
  2. Custom Thank You Page For WooCommerce – This plugin allows WooCommerce Shop Owners to send their customers to a different thank you page. But the page has to be set for each product separately.
  3. WC Custom Thank You – This WooCommerce extension allows you to define a custom Thank You page for your customers. This plugin allows you to set a page from the WooCommerce Settings page that is applicable to all products.

There are some paid plugins as well:

  1. Custom Thank You Pages Per Product for WooCommerce –  This plugin by StoreApps allows you to set a single custom Thank You page for all products as well as it allows you to set a different Thank You page per product.
  2. WooCommerce Redirect Thank You – This extension by Shop Plugins works in the same way as the earlier one. It allows you to set a custom Thank You page for individual products as well as globally for all products.
  3. NextMove – This plugin by XLPlugins is the premium version of NextMove Lite mentioned above. It boasts of 17 plug & play components that helps WooCommerce store owners boost sales & increase customer retention.

I haven’t reviewed any of the above plugins yet, I might be doing that in a separate post later so as to go in the pros & cons of each.

2. Customize the WooCommerce Thank You page by creating a Redirect

In another possible way, it will be rather simple to make redirection by creating a new plugin or opening the file functions.php that you can find in wp-content/themes/your-theme-name/ and enter the following code to the end of the file:

If you cannot view the above code snippet, please click here.

Below is the custom page shown after placing an order:

Customize WooCommerce Thank You page - WooCommerce Custom Thank You Page
WooCommerce Custom Thank You Page

Redirecting can be a nice option, but at the same time, above page is missing important things such as summary table of the order and some other important information that WooCommerce currently provides.

We will see how to add that in point 4 below.

3. Customizing WooCommerce Thank You page with Filters

3.a. Changing the Thank You page title

Instead of creating a Custom Thank You page as shown above, you might just want to change the title of the page.

You can add the below snippet in a plugin or in the theme’s functions.php file.

If you cannot view the above code snippet, please click here.

WooCommerce provides the function is_order_received_page() in includes/wc-conditional-functions.php file. This is how the changed title would appear:Customize WooCommerce Thank You page - WooCommerce Custom Thank You Page Title

 

3.b. Personalize the title

You can go one step forward & also personalize the Thank You page title to include details like the customer’s name, or anything else.

You can add the below code in a plugin or in your theme’s functions.php:

If you cannot view the above code snippet, please click here.

This is how the personalized title would appear:

Customize WooCommerce Thank You page - WooCommerce Personalized Thank You Page Title

3.c. Changing the text before order information

There are filters available in WooCommerce that allow you to also change the text shown on the Thank You page. By default, the text shown before the order information is “Thank you. Your order has been received.”.

This text comes from the file templates/checkout/thankyou.php. The filter available to change this text is: woocommerce_thankyou_order_received_text

If you cannot view the above code snippet, please click here.

Above code will append the text “We have emailed the purchase receipt to you.” to the existing text.

Customize WooCommerce Thank You page - WooCommerce Change Thank You Page Text

If you want to overwrite the text completely, you simply need to avoid concatenating the $str variable to your message variable $new_str.

$new = ' We have emailed the purchase receipt to you.';

If you want to add instructions here that need the customer to download a form, you can do that too.

If you cannot view the above code snippet, please click here.

This is how it would appear:

Customize WooCommerce Thank You page - WooCommerce Change Thank You Page Text & Add External Link

 

4. Customizing WooCommerce Thank You page by overwriting WooCommerce templates

WooCommerce shows the contents of the Thank You page from the thankyou.php template file that can be found in woocommerce/templates/checkout/ folder.

You will need some PHP knowledge if you want to choose this method of customizing your WooCommerce Thank You page.

You can use your own template by copying the thankyou.php file to your theme’s folder in a similar folder structure. So if you are using Twenty Seventeen theme, then your thankyou.php should be copied to: wp-content/themes/twentyseventeen/woocommerce/checkout/ folder. You will need to create the 2 folders, “woocommerce” & “checkout”.

When WooCommerce finds the same template is present in your own theme, then priority is given to the template present in your theme.

Let’s take an example. On the default thank you page, the Payment Method is shown in the Order Details as well as in the beginning:

Customize WooCommerce Thank You page - WooCommerce Default Thank You Template

I want to provide a coupon code to the customer for their next purchase & remove the Payment Method from the top section.

Customize WooCommerce Thank You page - WooCommerce Overwrite Thank You Template

Below is the thankyou.php template from my theme:

If you cannot view the above code snippet, please click here.

You might want to change the data shown in the Order details table & the customer details (when logged-in).

Those are coming from another file. WooCommerce uses a function woocommerce_order_details_table() that is attached to the woocommerce_thankyou hook. The function woocommerce_order_details_table() is defined in includes/wc-template-functions.php file.

The Thank You page is actually a collection of 4 different template files:

  • templates/checkout/thankyou.php
  • templates/order/order-details.php
  • templates/order/order-details-item.php
  • templates/order/order-details-customer.php

Below image shows which data comes from which template file:

Customize WooCommerce Thank You page - WooCommerce Thank You Page Template Structure
WooCommerce Thank You Page Template Structure

Once you know what data is coming from which template, you just need to copy the right template to your theme’s folder & that’s all.

5. Show different Thank You page for specific product or product attribute

5.a Redirect to a custom Thank You page based on product ID using hook

We saw in point 2 that you can redirect to a custom page with the template_redirect hook. Another way to redirect to a custom thank you page is by using the ‘woocommerce_thankyou‘ hook. This hook has one argument – order_id.

If you want to redirect to a custom page for only a specific product, you can do this by getting the order from order_id parameter & then loop through each item of the order. If one of the items has the product id you want, redirect to a custom thank you page using wp_redirect.

If you cannot view the above code snippet, please click here.

5.b. Show a custom Thank You page template based on product ID

As we saw in point 4, we can override the thank you page template from WooCommerce. But you may want to display different template based on product ID. When you override the thank you template in your theme, you can define some conditions to display different HTML for a particular product ID.

For example, if you want to change the thank you text for just one product, loop through the items from the order and get all product IDs, and check if the product you want is present in it. If it is present, display some custom thank you text for that order.

If you cannot view the above code snippet, please click here.

5.c. Redirect to a custom Thank You page based on variation ID using hook

This question was asked on the Facebook group Advanced WooCommerce as to how to show a different Thank You page for each attribute of a product.

The code is mostly similar to the one shown in 5.a above, with a slight change. Here it is:

If you cannot view the above code snippet, please click here.

6. Print text on Thank You page based on product attribute

Extending the above 5.c example, it is also possible to display any custom text on the WooCommerce Thank You page based on the variation id. Below is the code for it:

If you cannot view the above code snippet, please click here.

When the above code is added, this is how the Thank You page would appear:

Show Custom Text on WooCommerce Thank You Page by variation id

7. Building Your Own Thank You Page from scratch

I was initially thinking to write on this. But I realized that this post by Nicola Mustone covers that topic very well.

I hope that this post helps you to build the right layout for your WooCommerce Thank You page & get the most out of it.

References: Change your WooCommerce thank you page title by Barry Kooij.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

41
Leave a Reply

avatar
19 Comment threads
22 Thread replies
20 Followers
 
Most reacted comment
Hottest comment thread
20 Comment authors
RobinFarrukh ZAman KhanVantronTahira NaeemAlex Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest
Notify of
Karen
Guest
Karen

Thanks so much for the awesome how to! Wondering could I write a conditional statement with filters to show a custom thank you page for a product based on the product ID and any other product order to show the original thank you page? Thank you so much for your guidance!!!!

Pramathesh Palchoudhary
Guest
Pramathesh Palchoudhary

Is it possible to add a shortcode to thank you page? How would I go about doing the same?

Girish
Guest

I have a custom checkout page which is accessible for public which means anyone can access the page. How can I block the page after order placed and thank you page rendered?

Tamas
Guest
Tamas

Lifesaving post, thank you very much!

Stuart Edwards
Guest

Hey Vishal! Thanks for these bro – very helpful!

Managed to implement the ‘Changing the text’ part – worked perfectly.

I’ve struggled with the ‘Personalize the title’ part – it’s not displaying. I’ve used the exact code, minus the <?php part… but no luck!

Any ideas?

Here's my site: theroastclub.co

Thanks so much mate!!

Stu

from purchased

Subscribe Now