How to redirect customer to custom thank you page in Woocommerce?

In this tutorial we’ll learn how to redirect customers to a custom thank you page.

We can achieve this by using one of woocemmerce’s default hook.

Our team at Themelocation is comprised of WordPress developers of high expertise

  • We can maintain, support and manage your single, or all your clients, website with dedication
  • Our skills are at your disposal.

Book a Call

First of all create a custom page where you want your customers be redirected to upon successful order completion.

I’ve created a custom thank you page:

woocommerceNow we need to redirect our customers to this page upon successful order completion.

To do this add the following lines of code at the end of your theme’s functions.php file:

add_action( 'woocommerce_thankyou', function( $order_id ){
   $order = new WC_Order( $order_id );
   $url = 'http://localhost/wordpress/thank-you/';
   if ( $order->status != 'failed' ) {
       echo "<script type='text/javascript'>window.location = '".$url."'</script>";

You can access functions.php file here:


Replace the url of the page you wantyour customers to redirect with the one in the code.

Now whenever a customer will make a successful login, they will be redirected to the custom page instead of default checkout page.

Now, add products in cart and proceed to checkout.

woocommerceNo, place your order.

woocommerceAnd you’ll be redirected to custom thank you page!




I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

Leave a Comment

Your email address will not be published. Required fields are marked *