Home » WooCommerce: Redirect to Custom Thank you Page

WooCommerce: Redirect to Custom Thank you Page

by Tutor Aspire

How can you redirect customers to a beautifully looking, custom, product-specific thank you page?

Thankfully you can add some PHP code to your functions.php and define a redirect to a custom URL (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, social media share and other information that could help you convert additional sales. 

WooCommerce Redirect Custom Thank You Page
WooCommerce Redirect to a Custom Thank You Page URL

PHP Snippet: Redirect to Custom Thank you Page – WooCommerce

 * @snippet       WooCommerce: Redirect to Custom Thank you Page
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://tutoraspire.com
add_action( 'woocommerce_thankyou', 'tutoraspire_redirectcustom');
function tutoraspire_redirectcustom( $order_id ){
    $order = wc_get_order( $order_id );
    $url = 'https://yoursite.com/custom-url';
    if ( ! $order->has_status( 'failed' ) ) {
        wp_safe_redirect( $url );

“Redirection won’t work for me?”

I was recently working on a client’s website and used the snippet above – nothing was working. I even tried to use a redirection plugin (Simple 301 Redirects), but that didn’t work either.

Here’s what I found out: while editing the WooCommerce Endpoints settings, he left a blank space between “Order” and “Received” (see image below, text is translated badly by Google from Danish to English).

That was it!

Broken Thank You Page and Redirect Won't work either!
Broken Thank You Page and Redirect Won’t work either!

“I don’t code – is there a trustworthy plugin for that?”

As many readers would love to code but don’t feel 100% confident with it, I decided to look for a reliable plugin that achieves the same result.

In this case, I recommend the YITH Custom Thank You Page for WooCommerce plugin. On top of picking your custom redirect URL, you can also define a different thank you page by category/product, show/hide default information, enable social sharing, display upsells and much more.

But in case you wish to code, keep reading 🙂

You may also like