Menu Close

WooCommerce: Redirect to Custom Thank you Page

default

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

Thankfully you can add some PHP code to your functions.php or install a simple plugin and define a redirect to a custom WordPress page (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. 

The default Thank You page in WooCommerce

PHP Snippet: Redirect to Custom Thank you Page – WooCommerce

/**
 * @snippet       WooCommerce: Redirect to Custom Thank you Page
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 7
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_action( 'woocommerce_thankyou', 'bbloomer_redirectcustom');
 
function bbloomer_redirectcustom( $order_id ){
    $order = wc_get_order( $order_id );
    $url = 'https://yoursite.com/custom-url';
    if ( ! $order->has_status( 'failed' ) ) {
        wp_safe_redirect( $url );
        exit;
    }
}

“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!

Mini-Plugin: Business Bloomer WooCommerce Redirect To Custom Thank You Page

You don’t feel confident with coding? You don’t want to purchase yet another bloated, expensive plugin? Great!

Business Bloomer WooCommerce Redirect To Custom Thank You Page is a mini WooCommerce plugin, without the usual hassles. One feature. Lifetime license. No annoying subscriptions. 1 plugin file. A few lines of code. No banners. No up-sells. No WP notifications. Use it on as many websites as you like. Lifetime support. 1-page documentation. A super simple settings dashboard.

Screenshot of the settings:

Quick demo:

As you can see the settings are pretty straight forward. Select a WordPress page from the dropdown, and automatically redirect successful orders to that page.. You can even “append” the order key to the URL, and print the order details on the custom page via a shortcode. Simple!

Advanced Plugin Alternative

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 🙂

View Source
Posted in WooCommerce Tips