Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Redirect Customers to Custom Pages Based on WooCommerce Order Status?

This customization is useful when you want your customers to get redirected to a specific page based on order status. From directing customers to customized thank you pages or to return and refund policy page, these tailored redirects ensure a smooth post-purchase journey.

Solution: Redirect Customers to Custom Page Based on WooCommerce Order Status

The code snippet below will redirect customers to the link provided in the code. Customers are redirected to the specific custom page based on the order status ‘ processing’ as specified in the code.

add_action( 'woocommerce_thankyou', 'ts_redirect_custompage');
function ts_redirect_custompage( $order_id ){
    $order = wc_get_order( $order_id );
    $url = 'http://localhost/wpsite/wordpress/refund_returns/';
    if ( $order->has_status( 'processing' ) ) {
         wp_redirect( $url );
         exit;
    }
    
}

Output

When a customer places an order and the status is set to ‘Processing,’ they are redirected from the default thank you page to the refund returns page, as specified in the code.



Alternatively, you can customize the default thank you page title and dynamically show different titles according to the WooCommerce order status.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.