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:
Here are the steps you should follow:
- Log into your WordPress site and access the Dashboard as the admin user.
- 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.
- 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; } }
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:
- Log into your WordPress site and access the Dashboard as the admin user.
- 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.
- 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 :)'; }
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!'; }
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.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- Hide or Remove the Quantity Field from WooCommerce Product Page
- How to Disable Payment Method for Specific Category
- How to Hide Tags In Storefront Theme WooCommerce
- How to Remove Related Products WooCommerce Storefront Theme
- How to Hide Category WooCommerce Storefront Theme
- How to Use WooCommerce Product Attributes Step by Step [Complete Guide]
- How to Hide Read More and Add to Cart Button WooCommerce
- How to Remove Breadcrumbs WooCommerce Storefront
- How to Hide Trailing Zeros WooCommerce
- How to Hide & Rename Addresses Tab My Account Page WooCommerce
- How to Hide WooCommerce Product Count
- How to Hide SKU, Category, Tags Meta Product Page WooCommerce
- How to Hide Product Tab Title In WooCommerce
- How to Hide Product SKU In WooCommerce
- How to Add WooCommerce Custom Checkout Message
- How to Add Custom Order Status in WooCommerce
- How to Hide Dashboard on the My Account Page WooCommerce
- How to Change Button Color Storefront Theme
- How to Hide Product Prices Based on User Role Storefront
- How to Change Storefront Theme Order of Products