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
 * @community     https://businessbloomer.com/club/
 */
 
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 custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Add Content to a Specific Order Email
    Customizing WooCommerce emails via the WordPress dashboard is not easy and – sometimes – not possible. For example, you can’t edit or add content to them unless you’re familiar with code. Well, here’s a quick example to learn how to add content to any WooCommerce default order email. In this case study, our goal is […]
  • WooCommerce: How to Add a Custom Checkout Field
    Let’s imagine you want to add a custom checkout field (and not an additional billing or shipping field) on the WooCommerce Checkout page. For example, it might be a customer licence number – this has got nothing to do with billing and nothing to do with shipping. Ideally, this custom field could show above the […]
  • WooCommerce Visual Hook Guide: Emails
    WooCommerce customizers: the Visual Hook Guide is back! Here’s a visual HTML hook guide for the WooCommerce Emails. This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations. Let me know in the comments if this […]
  • WooCommerce: Add To: Cc: Bcc: Email Recipients
    The WooCommerce Email Settings allow you to add custom recipients only for New Order, Cancelled Order, Failed Order and all admin-only emails. But what if you want to add an email recipient to a customer email e.g. the Completed Order one? For example, you need to send it to your dropshipper. Also, you might want […]
  • WooCommerce: Remove Link to Product @ Order Table
    There is a slightly annoying thing on the WooCommerce Thank-You Page and WooCommerce emails. Users looking at the order table can actually click on the Products they just purchased and abandon the page before taking the action you want them to take (see image below). So, I coded a simple PHP snippet to remove such […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent 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. Follow @rmelogli

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

  1. Hello. Sorry, English is not my native language.
    I only have one product per order. It is possible to add the product name in the subject field of the email to the admin?

    1. Hello Arthur, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. You code works, but in my case the name is left out. i.e. the billing_first_name is blank.

    Its like it is not fetching the billing_first_name from the database. – do you have any suggestions?

    1. Hi Clifford, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet.

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentytwenty” theme (load the snippet there in functions.php) as explained here: https://www.businessbloomer.com/lesson/trwm4l01/

      Once you do that, does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!

  3. Is there a way to add Billing First Name to Order email customer details section only?

    1. Hi Diksha, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. Hi,

    how can I change E-Mail Sender Name (woocommerce_email_from_name) into “Billing First & Last Name” from User.

    For Example: My Shop should be changed to John Doe!
    Can anyone help me?
    Thanks.

    1. Hi Nero, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. 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

  6. 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 🙂

  7. 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

  8. 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

  9. 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 🙂

  10. 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!

  11. 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

  12. 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 🙂

  13. 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! 🙂

  14. 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 🙂

  15. 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/

  16. 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? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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