Adding customer name to Woocommerce email template with php

I’m new to Woocommerce, and I’m trying to show the name of the customer in the beginning of the email.

So the email will look something like this:

[HEADER]You order has been placed [/HEADER]

[H2]Hi {CUSTOMER_NAME}[/H2]

[P]Some text[/P]

[THE REST OF THE MAIL]

I’ve tried adding something like this to functions.php in my theme.

//add the first name of the person to the email. 
add_filter('woocommerce_email_order_details','name_to_processing_customer_email', 10, 3);
function name_to_processing_customer_email( $order, $sent_to_admin, $plain_text, $email ) {

    if( 'customer_processing_order' == $email->id ){

        // Set here as you want your custom content (for customers and email notification related to processing orders only)
        echo '<h2>Hej '.$order->billing_first_name .'</h2>';

    }

}

But this doesn’t work.
Can someone help?

Read more here: Adding customer name to Woocommerce email template with php

Leave a Reply

Your email address will not be published. Required fields are marked *