How to Change WooCommerce Thank You Page

Change WooCommerce Thank You Page

The WooCommerce thank you page is very important in every WooCommerce store.

If you want customers to take time to examine your WooCommerce thank you page, due to its creativity and design, then you are in the right place.

By default, WooCommerce technically offers you a thank you page.

You may want to customize the basic WooCommerce thank you page by including other crucial elements.

Change WooCommerce Thank You Page

In this post, you’ll learn how to create a redirect to the custom page you’ve created. We will also share how you can change elements like the title and the text before ordering information.

We will use hooks to customize these elements.

You can use plugins, but hooks are the recommended way to make crucial changes.

But you should be very careful as a single error will break down your site.

We also recommend using a child theme so that you won’t lose your chances when an update occurs.

Let us change the WooCommerce thank you page.

a)    Steps to Change WooCommerce Thank You Page by Creating a Redirect

This is how the thank you page is displayed in the storefront theme:

default thank you page

Here are the steps you should follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file where we will add the function that will change WooCommerce thank you page by creating a redirect. Remember to add the correct link.
  3. Add the following code to the PHP file:
/**

 * @snippet       Change WooCommerce Thank You Page by Creating a Redirect

*/

add_action( 'template_redirect', 'njengah_custom_redirect_after_purchase' );

function njengah_custom_redirect_after_purchase() {

            global $wp;

            if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {

                        wp_redirect( 'Paste Link Here' );

                        exit;

            }

}

This is the outcome:custom thank you page

b)    Steps to Change the Thank You Page Title

If you do not want to create a custom thank you page, as shown above, you can change the title of the page.

Here are the steps you should follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file where we will add the function to change the thank you page title.
  3. Add the following code to the PHP file:
/**
 * @snippet       Change WooCommerce Thank You Page Title
*/

function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {

            return abs( (float) $expected - (float) $actual ) <= $precision;

}

add_filter( 'woocommerce_endpoint_order-received_title', 'njengah_thank_you_title' );

function njengah_thank_you_title( $old_title ){

            return 'New Title Here :)';

 }

This is the outcome:change title

If you want to go one step forward and also personalize the text under the thank you page title, add the following code in the functions.php file:

/**

 * @snippet       Change WooCommerce Text Under Thank You Page Title

*/

add_filter( 'woocommerce_thankyou_order_received_text', 'njengah_thank_you_title', 20, 2 );

 function njengah_thank_you_title( $thank_you_title, $order ){

            return 'Dear ' . $order->get_billing_first_name() . ', thank you so much for your order!';

 }

This is the outcome:change text under title

Conclusion

In this post, you have learned how to redirect customers to your custom thank you page using a PHP snippet.

You’ve also learned how to change the title, and the text on the thank you page.

If you have any problems please contact an experienced WoooCommerce developer.

Similar Articles