Personal Thank-You Message After Purchase
Replaces the standard "Thank you. Your order has been received." text with a friendlier message that includes the customer first name.
Opens WPIDE on
Code
add_filter( 'woocommerce_thankyou_order_received_text', function ( $text, $order = null ) {
$name = $order instanceof WC_Order ? $order->get_billing_first_name() : '';
if ( '' === $name ) {
return 'Thank you! Your order has been received and a confirmation email is on its way.';
}
return sprintf( 'Thank you, %s! Your order has been received and a confirmation email is on its way.', esc_html( $name ) );
}, 10, 2 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.