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

How to Customize Thank You Page Title Based on WooCommerce Order Status?

Customizing the WooCommerce thank you page is one great place to include personalized messages to your customers. This post lets us customize the title to provide more relevant and personalized messaging to customers depending on their order status.

This post is restricted to customizing just the title based on order status. But if you are looking for a hardcore thank you page customization, check out our complete guide on WooCommerce Thank you page customization.

Solution: Customize Thank You Page Title Based on WooCommerce Order Status


The code snippet will dynamically display the modified title based on the order statuses ‘on hold’, ‘processing’, and ‘completed’, as specified within the code.

add_action( 'the_title', 'ts_change_order_received_page_title_based_on_order_status' );
function ts_change_order_received_page_title_based_on_order_status( $title ){
    if ( is_wc_endpoint_url('order-received') && $title === 'Order received' ) {
        global $wp;

        // Define the targeted statuses and their corresponding messages
        $statuses_messages = array(
            'on-hold' => __("Order request received", "woocommerce"),
            'processing' => __("Order request received. It is processed and will be shipped soon.", "woocommerce"),
            'completed' => __("Order request received. Your order is complete.", "woocommerce"),
        );

        // Get an instance of the `WC_Order` Object
        $order = wc_get_order( absint($wp->query_vars['order-received']) );

        if ( is_a( $order, 'WC_Order' ) && isset( $statuses_messages[$order->get_status()] ) ) {
            return $statuses_messages[$order->get_status()];
        }
    }
    return $title;
}

Output

When the order information is successfully retrieved and if the order status corresponds to one of the defined statuses in $statuses_messages, the corresponding custom title is displayed on the Order Received Page.

Customize Thank You Page Title Based on WooCommerce Order Status

If the order is set to the status of ‘processing’ the following custom message will be shown.

How to Customize Thank You Page Title Based on WooCommerce Order Status? - Tyche Softwares

You can show personalized messages based on order status on the â€śMy Account Page” as well. We have made a dedicated post on how to filter order status in the My Account ‘Orders’ section; take a look at it to deliver a personalized user experience throughout your site.

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