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.

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!



About the author

We provide WordPress & WooCommerce Support, Maintenance and Development Services.

Leave a Reply