Can I Redirect Customers After WooCommerce Checkout?
How to Redirect After WooCommerce Checkout
The woocommerce_thankyou action passes the order ID, giving access to full order details before deciding where to redirect — this makes it possible to build conditional logic (redirect only for a specific product, or only for first-time customers, for instance) rather than a single, blanket redirect for every order.
add_action( 'woocommerce_thankyou', function( $order_id ) {
if ( ! $order_id ) {
return;
}
wp_safe_redirect( home_url( '/thank-you-custom/?order=' . $order_id ) );
exit;
} );
Things Worth Getting Right
- Passing the order ID through to the custom page if it needs to display order-specific content, since the redirect can include it as a query parameter for the destination page to read.
- Conditional redirects based on product, order total, or customer type need the logic built into the same hook, checking order details before deciding whether (and where) to redirect.
- Analytics and conversion tracking scripts that expect to fire on the default order-received page need to be moved to the new custom page instead, or duplicated there, to avoid losing tracking data after this change.
- Testing with a real completed order (not just a page preview) is essential, since this hook only fires in the actual post-checkout flow.
Implementing the Redirect Properly
- Use the
woocommerce_thankyouhook with a safe redirect, including the order ID if the destination page needs it. - Move any conversion tracking scripts from the default template to the new custom destination.
- Test with real completed orders across different scenarios if the redirect is conditional.
Need a custom post-purchase flow built and properly tracked? See custom WooCommerce development.