The default “Order Received” heading on the WooCommerce Thank You page can be customized to suit your store’s branding or messaging better. By using a simple code snippet, you can replace this default heading with a custom one.
Change Thank You Page Heading
/**
* Snippet Name: Change Thank You Page Heading
* Snippet Author: wpsnippets.dev
*/
//changing "order received" heading
function wps_custom_thankyou_page_heading( $thankyou_title, $order ) {
// Change the thank you page heading here
$thankyou_title = 'Your Custom Thank You Heading';
return $thankyou_title;
}
add_filter( 'woocommerce_endpoint_order-received_title', 'wps_custom_thankyou_page_heading', 10, 2 );
Code Explanation
- This code snippet uses the woocommerce_endpoint_order-received_title filter hook to modify the heading displayed on the Thank You page.
- The custom_thankyou_page_heading function takes two parameters: the default heading ($thankyou_title) and the order object ($order).
- Inside the function, the $thankyou_title variable is assigned the desired custom heading text.
- Finally, the modified heading is returned to be displayed on the Thank You page.