Personal Email Headings With the Customer's Name
Changes the headings of customer order emails to greet the customer by first name, for example "Thanks for your order, Anna!".
Opens WPIDE on
Code
$wpide_email_headings = array( // Email ID => heading.
'customer_processing_order' => 'Thanks for your order, {first_name}!',
'customer_completed_order' => 'Good news, {first_name}: it is on its way!',
'customer_on_hold_order' => 'We have received order #{order_number}',
);
foreach ( $wpide_email_headings as $wpide_email_id => $wpide_heading ) {
add_filter( 'woocommerce_email_heading_' . $wpide_email_id, function ( $heading, $order ) use ( $wpide_heading ) {
if ( ! $order instanceof WC_Order || ! $order->get_billing_first_name() ) {
return $heading;
}
return strtr( $wpide_heading, array(
'{first_name}' => $order->get_billing_first_name(),
'{order_number}' => $order->get_order_number(),
) );
}, 10, 2 );
}
Notes
Edit the headings in $wpide_email_headings; {first_name} and {order_number} are replaced.
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.