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.
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
- Use a Child Theme: Always implement these changes in a child theme to ensure your modifications are preserved during theme updates.
- Backup Regularly: Regularly back up your
functions.phpfile to avoid losing customisations. - Keep It Relevant: Ensure that the page you’re redirecting users to is relevant and adds value to their shopping experience.
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.
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Stay In Touch


Thanks for the post. What if I want to redirect only for a specific product
To redirect for a specific product you’ll need to check the cart for a specific product ID. If the cart contains the ID the thank you page will be redirected
// Define the product ID for which the redirect should happen $specific_product_id = 123; // Replace with your product ID // Loop through order items to check if the specific product is in the order foreach ( $order->get_items() as $item ) { if ( $item->get_product_id() == $specific_product_id ) { $redirect_url = 'https://yourdomain.com/custom-page'; // Replace with your custom redirect URL break; } }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.
You’re welcome @Tayo. That plugin is a good plugin, however, if you want to reduce plugin overhead custom code is the best way to do it.