WooCommerce: Add First Name to Order Email Subject

Today we take a look at the WooCommerce Emails and specifically at how to change the subject of the Customer Processing Order email by adding the billing “First Name”. As usual, this is a matter of 3 lines of PHP code – feel free to copy/paste and customize it to your liking 🙂

WooCommerce: change subject of the customer processing order email
WooCommerce: change subject of the customer processing order email

PHP Snippet: Add Billing First Name to Order Email Subject

/**
 * @snippet       Add Billing First_name to Email Receipt (Customer Processing)
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_filter( 'woocommerce_email_subject_customer_processing_order', 'bbloomer_change_processing_email_subject', 10, 2 );
 
function bbloomer_change_processing_email_subject( $subject, $order ) {
   $subject = $order->get_billing_first_name() . ', thanks for your order!';
   return $subject;
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

24 thoughts on “WooCommerce: Add First Name to Order Email Subject

  1. Hi please I want to remove costumer e-mail and phone number from new e-mail how do I do that?

    1. Hello there, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  2. Hi, this is causing an error in my PHP log

    billing_first_name was called incorrectly. Order properties should not be accessed directly.

    Backtrace: require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::do_wc_ajax, do_action(‘wc_ajax_checkout’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::checkout, WC_Checkout->process_checkout, WC_Checkout->process_order_payment, WC_Stripe_Subs_Compat->process_payment, WC_Gateway_Stripe->process_payment, WC_Stripe_Payment_Gateway->process_response, WC_Order->payment_complete, WC_Order->save, WC_Order->status_transition, do_action(‘woocommerce_order_status_pending_to_processing’), WP_Hook->do_action, WP_Hook->apply_filters, WC_Emails::send_transactional_email, do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, WC_Email_Customer_Processing_Order->trigger, WC_Email->get_subject, apply_filters(‘woocommerce_email_subject_customer_processing_order’), WP_Hook->apply_filters, bbloomer_change_processing_email_subject, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong. This message was added in version 3.0.

    1. 100% right Ruth! Snippet has now been revised 🙂

  3. Hi,

    I wrote in subject:
    $subject = $order->billing_first_name . ‘, il tuo ordine è stato spedito!’;
    but in email ‘è’ appear ‘?’ char,

    how can I fix it?

    1. Ciao Domenico, thanks for your comment. I’m not 100% sure why, it should encode that special character by default. Try taking a loook at https://stackoverflow.com/questions/29069667/all-special-characters-are-question-marks-in-php-html

  4. Hi.
    The code is working fine, but i want something different and i can’t make it work. I need to have a email headind that looks like this : Hi, {customer_name}. It looks simple but i did not find the solution. Is there a solution? Thank you.

    1. Ciao Beppe, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  5. Hi!

    Is there an option to use always first name as salutation in the mail subject, no matter whats in the email?

    Thanks!

    1. Hey Hansimglück thanks for your comment! You can add more email types by using extra filters. I’m using “woocommerce_email_subject_customer_processing_order” but you can also use “woocommerce_email_subject_XYZ”, where “XYZ” is the ID of the email you like 🙂

  6. Hello Rodolfo,

    Your tips are amazing! It really helped me to figure out how to customise the emails. At one point i can’t find any help or information on the web: How do actually change the standart text in the Emails (for example the one from the processing-email: Your order has been received and is now being processed. Your order details are shown below for your reference:). I really would like to add the customer name there without a big mess and overriding templates. Do you know an easy way?

    1. Hey Simon, thanks for your comment! The only way to edit that without overriding the email template is probably to echo your new message with the hook “woocommerce_email_order_details” (use priority < 10 so it shows before the order table), and then hide the default WooCommerce message with CSS I guess. Hope this helps!

  7. Is there a way to strip out the download link in customer-completed-order email?

    1. Hal, thanks for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  8. hii i want to add account number of buyer and seller in order details and emails

    1. Hey Bhavik, sorry but this is custom work and I can’t help this time 🙂

  9. Is there a way/snippet that let’s you put the category of a product to the email?
    I just can’t find any good information on how to get to that data. (I think it is woocommerce_order_item_meta data?)

    1. Hello Hans, thanks for your comment! Try watching my video tutorial here: https://businessbloomer.com/customize-emails-woocommerce, it should help you hopefully! 🙂

  10. Just a question – Will this work 🙁 ? I need to add invoice No

    add_filter(‘woocommerce_email_subject_customer_completed_order’, ‘bbloomer_change_processing_email_subject’, 10, 2);

    function bbloomer_change_processing_email_subject( $subject, $order ) {
    global $woocommerce;
    $subject = $order->billing_first_name . ‘, Thanks for your ‘ . get_bloginfo( ‘name’, ‘display’ ) . ‘ Order!’ .. ‘Invoice No’;
    return $subject;
    }

    1. Sorry Prachi, this is custom to the Invoice plugin you’re using. You need to check how to get the Order Number from there 🙂

  11. Great 🙂
    Can I add something similar to First_name to Email when an order has been completed ? Which is the respective hook ?

    1. Prachi, thanks for your comment! Of course – just change woocommerce_email_subject_customer_processing_order with woocommerce_email_subject_customer_completed_order. Docs here: https://docs.woothemes.com/document/change-email-subject-lines/

  12. Where do you add this snippet?

    1. Hey, thanks for your comment! You should add this snippet in the functions.php file of your child theme. This free video training I recorded may help you 🙂 Thank you!

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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