1

I am using Woocommerce and try to customize the emails. In the email title I've tried to use {customer_first_name} and {customer_name} with no luck. They do not get replaced. Is this a bug or are the strings I use incorrect?

closed as off-topic by Jacob Peattie, Krzysiek Dróżdż, Howdy_McGee May 16 '18 at 0:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

The email template variables can only be used in the body of the emails. If you want to change the email titles/subject lines then you would need to use a the corresponding filter and add some custom code to a child themes functions.php file or via a custom plugin.

The WooCommerce documentation has a snippet for doing this: https://docs.woocommerce.com/document/change-email-subject-lines/

As an example for the processing order you would use:

add_filter( 'woocommerce_email_subject_customer_processing_order', 'change_processing_email_subject', 1, 2 );

function change_processing_email_subject( $subject, $order ) {
    global $woocommerce;

    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

    $subject = sprintf( 'Hi %s, thanks for your order on %s', $order->billing_first_name, $blogname );

    return $subject;
}

This would change the subject to:

'Hi {customer first name}, thanks for your order on {website name}'

Not the answer you're looking for? Browse other questions tagged or ask your own question.