How to Redirect WooCommerce Users After Checkout – 2026

Last updated on September 2nd, 2024 at 08:22 am

Redirecting customers after they complete a purchase in your WooCommerce store can be a powerful way to guide them to additional content, upsell products, or simply enhance their shopping experience. In this guide, we’ll show you how to set up a custom redirect after checkout using your theme’s functions.php file. This method avoids the need for additional plugins, ensuring your site remains fast and lightweight.

Why Custom Redirects Matter

Custom redirects after checkout can help improve customer engagement by guiding users to relevant content, encouraging them to leave a review, or offering them a special discount on their next purchase. By adding this functionality directly to your theme’s functions.php file, you maintain full control over the redirect process without relying on third-party plugins.

Getting Started

Before making any changes, ensure you’re working within a child theme to prevent losing customisations when updating your main theme. If you haven’t created a child theme yet, use our free child theme generator to set one up quickly.

Adding a Custom Redirect After Checkout

To redirect users after a successful checkout, you’ll need to add a custom function to your theme’s functions.php file. The following code snippet will redirect customers to a custom thank you page after they’ve completed their purchase.

/**
 * Snippet: How to Redirect WooCommerce Users After Checkout – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1445
* Tested with WooCommerce 10.7.0
* "Redirects users to a custom thank you page after checkout"
*/ function wcsuccess_redirect_after_checkout( $order_id ) { $order = wc_get_order( $order_id ); $redirect_url = get_permalink( wc_get_page_id( 'thankyou' ) ); return $redirect_url; } add_filter( 'woocommerce_thankyou', 'wcsuccess_redirect_after_checkout' );

In this example, the wcsuccess_redirect_after_checkout function is hooked to the woocommerce_thankyou filter. This function gets the order details and then redirects the user to the default WooCommerce thank you page. You can customise the $redirect_url variable to point to any page you prefer.

Customising the Redirect URL

If you want to redirect users to a different page, such as a custom upsell page or a special offer, simply change the URL in the $redirect_url variable.

/**
 * Snippet: How to Redirect WooCommerce Users After Checkout – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1445
* Tested with WooCommerce 10.7.0
* "Redirects users to a custom upsell page after checkout"
*/ function wcsuccess_redirect_after_checkout( $order_id ) { $redirect_url = 'https://yourdomain.com/custom-upsell-page'; return $redirect_url; } add_filter( 'woocommerce_thankyou', 'wcsuccess_redirect_after_checkout' );

This snippet will redirect users to a custom upsell page after they complete their purchase. Ensure the URL is correct and points to a page that aligns with your marketing strategy.

See also  How to Restrict Coupon Usage Based on Payment Gateway in WooCommerce - 2026

Conditional Redirects Based on Order Details

You can also set up conditional redirects based on order details, such as the total order amount or specific products purchased. The following example shows how to redirect users to a different page if their order total exceeds a certain amount.

/**
 * Snippet: How to Redirect WooCommerce Users After Checkout – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1445
* Tested with WooCommerce 10.7.0
* "Conditional redirect based on order total"
*/ function wcsuccess_conditional_redirect_after_checkout( $order_id ) { $order = wc_get_order( $order_id ); $order_total = $order->get_total(); if ( $order_total > 100 ) { $redirect_url = 'https://yourdomain.com/special-offer'; } else { $redirect_url = get_permalink( wc_get_page_id( 'thankyou' ) ); } return $redirect_url; } add_filter( 'woocommerce_thankyou', 'wcsuccess_conditional_redirect_after_checkout' );

In this example, customers who spend more than $100 will be redirected to a special offer page, while others will be taken to the default thank you page.

Testing the Redirect

Before going live with your redirect, it’s essential to test the functionality to ensure it works as expected. Make sure to test with different scenarios, such as varying order totals or different products, to confirm that the redirect behaves as intended.

Removing the Custom Redirect

If you need to remove the custom redirect, you can do so by simply removing the function from your functions.php file.

/**
 * Snippet: How to Redirect WooCommerce Users After Checkout – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1445
* Tested with WooCommerce 10.7.0
* "Removes the custom redirect function"
*/ function wcsuccess_remove_redirect_after_checkout() { remove_filter( 'woocommerce_thankyou', 'wcsuccess_redirect_after_checkout' ); } add_action( 'init', 'wcsuccess_remove_redirect_after_checkout' );

Best Practices

  1. Use a Child Theme: Always implement these changes in a child theme to ensure your modifications are preserved during theme updates.
  2. Backup Regularly: Regularly back up your functions.php file to avoid losing customisations.
  3. Keep It Relevant: Ensure that the page you’re redirecting users to is relevant and adds value to their shopping experience.
See also  Reordering WooCommerce checkout fields 2026

Conclusion

Setting up a custom WooCommerce redirect after checkout is a simple yet powerful way to enhance user engagement and boost sales. By adding this code directly to your child theme’s functions.php file, you maintain control over the redirect process while keeping your site lightweight and free from plugin dependencies. Don’t forget to create a child theme before making any changes, and consider testing different redirect strategies to see what works best for your audience.

By following this guide, you’ll be well-equipped to create a tailored and effective checkout experience for your WooCommerce store.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Tayo
Tayo
November 19, 2024 7:49 am

Thanks for the post. What if I want to redirect only for a specific product

Tayo
Tayo
Reply to  John Cook
November 19, 2024 9:09 am

Thank you!

I found a work-around by using a custom thank you page plugin (https://wordpress.org/plugins/woo-thank-you-page-nextmove-lite/) and then redirected that page on load… I’ll just leave it as it is, so I don’t break what already works. Thanks again ffor the prompt response.

Scroll to Top
4
0
Would love your thoughts, please comment.x
()
x
×