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 resource is helpful and how. Enjoy!

WooCommerce Email Hooks

New customer order

woocommerce_email_header ($email_heading, $email)

You have received an order from fdgfg dfgfdg. The order is as follows:

woocommerce_email_order_details ($order, $sent_to_admin, $plain_text, $email)woocommerce_email_before_order_table ($order, $sent_to_admin, $plain_text, $email)

Order #19950 ()

Product Quantity Price
Simple Product
woocommerce_order_item_meta_start($item_id, $item, $order, $plain_text)
woocommerce_order_item_meta_end ($item_id, $item, $order, $plain_text)
1 180.49(ex. VAT)
Subtotal: 180.49(ex. VAT)
Shipping: Free Shipping
Tax: 41.51
Payment Method: Direct Bank
Transfer
Total: 222.00

woocommerce_email_after_order_table ($order, $sent_to_admin, $plain_text, $email)woocommerce_email_order_meta ($order, $sent_to_admin, $plain_text, $email)woocommerce_email_customer_details ($order, $sent_to_admin, $plain_text, $email)

Customer details

  • Email: test@test.com
  • Tel: 345435

Billing address

Rodolfo Melogli
dfgdfg
dfgdfg
dfgfdgfg
00000
ghsfghgfh

Shipping address

Rodolfo Melogli
dfgdfg
dfgdfg
dfgfdgfg
00000
ghsfghgfh

woocommerce_email_footer($email)

WooCommerce Email Default add_actions

// --------------------------------------
// These are actions you can unhook/remove!
// You must use $object inside remove_action
// Where $object = WC()->mailer();
// --------------------------------------

// Email Header, Footer and content hooks

add_action( 'woocommerce_email_header', array( $object, 'email_header' ) );
add_action( 'woocommerce_email_footer', array( $object, 'email_footer' ) );
add_action( 'woocommerce_email_order_details', array( $object, 'order_details' ), 10, 4 );
add_action( 'woocommerce_email_order_details', array( $object, 'order_schema_markup' ), 20, 4 );
add_action( 'woocommerce_email_order_meta', array( $object, 'order_meta' ), 10, 3 );
add_action( 'woocommerce_email_customer_details', array( $object, 'customer_details' ), 10, 3 );
add_action( 'woocommerce_email_customer_details', array( $object, 'email_addresses' ), 20, 3 );
add_action( 'woocommerce_email_order_details', array( $this, 'generate_order_data' ), 20, 3 );
add_action( 'woocommerce_email_order_details', array( $this, 'output_email_structured_data' ), 30, 3 );

// New Order email only

add_action( 'woocommerce_email_footer', array( $this, 'mobile_messaging' ), 9 ); 

// Customer emails if BACS / COD / cheque payment

add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 );

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: 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 […]
  • WooCommerce: Add CSS to Order Emails
    Unlike your WordPress theme, you can’t just add CSS to your style.css in order to customize the look of the WooCommerce emails. This handy PHP snippet is therefore the only viable solution. It’s a little tricky but once you get the idea, adding CSS to Order Emails is a breeze.

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

93 thoughts on “WooCommerce Visual Hook Guide: Emails

  1. Very good Site. Just a godsend for the WP admin! Please tell me, is it possible to somehow display the client’s first and last name in the subject of a letter about a new order?

  2. I have a script that adds a profileID to a specific product when that product is ordered. The script works as expected except for one thing. When the new order email is generated and sent to the store manager the profileID is not in the order details. That profileID appears in every other email and in the order details in the admin area. I am sure it is because the profileID is being added after the new order email is generated, but am not sure what hook to use to make it add after payment and before emails are generated. Any suggestion of what hook to use for this.

    1. Which hook do you use now to attach the custom field value?

  3. Hello, Rodolfo.
    Please clarify what exactly you want to say with: “You must pass $object to the function”.
    Can you give us an example of “$object” for the sake of understanding?
    Screenshot: https://www.screencast.com/t/yJ6NDDtgTAsM
    Thank you!

    1. You’re right, not clear at all.

      In order to remove e.g.

      add_action( 'woocommerce_email_header', array( $object, 'email_header' ) );

      you need to use (untested):

      add_action( 'woocommerce_email_header', 'bbloomer_remove_email_header', 1 );
      
      function bbloomer_remove_email_header( $object ) {
         remove_action( 'woocommerce_email_header', array( $object, 'email_header' ) );
      }
      
  4. HI Rodolfo,

    I love your site it is a treasure trove of resources.

    I am wondering if it’s possible to add the PRODUCT DESCRIPTION to the CONFIRMATION EMAIL using a snippet.

    I am using Oxygen Builder and Kadence Email Customizer on the site.

    Thanks for your help

    1. Hi Demetre, 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. is it possible to obtain the total number of the quantity of the products and write it under the subtotal heading?

    1. Hello Nicola, 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!

  6. Hi Rodolfo, thank you very much for such professional and detailed work,
    In the case of downloadable products, the emails show the order details and the download in different tables placing the download’s table first, can this order be changed ?
    In other words, the order detail can be placed over the download detail table?
    I’ve tried to change the email templates, using a child theme don’t worry … both tables are entered with the ‘woocommerce_email_order_details’ hook but they don’t come from the same template and it’s a bit confusing ..

    Thank you in advance 🙂

    1. Hello Enson, 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!

  7. Hey Rodolfo,

    After so many tries, I am finally here to ask you for your help!

    Actually, My question and issue is with WooCommerce Email Templates,
    In My Order email, When I see my order email in Gmail, It turns any email texts as links, and applying their own style which is blue. That I need to update colors. I have tried many solutions but none of them works for me.

    Can you please help me?
    Thanks in advance!

  8. Happy New Year Rodolfo and thank you for that great overview. I have one more question, however. Is it possible to hide the element with the OrderID and the order date in front of the table? It seems like an element of the

    do_action ('woocommerce_email_order_details', $ order, $ sent_to_admin, $ plain_text, $ email);

    to be. A customer of mine would like to have his own introduction and find that annoying.

    Best regards
    Arnim

    1. Hi Arnim, 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!

  9. Hey Rodolfo, I think this woocommerce_email_order_meta should be woocommerce_email_order_meta_fields. I tried yours but it keeps giving me errors when trying to checkout.

    Appreciate all your work!

    1. Thanks for your feedback Stan, no, that should still work. What code did you write?

  10. Hello
    how can i add Labels to each address line detail in the new order email sent from woocommerce
    for example:
    Billing Address:
    Country : USA
    Street : 5
    City: NY
    ……

    1. Hi Khalid, 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!

  11. Thanks for this helpful article.

    1. You’re welcome!

      1. Hey, You are a lifesaver, you know?

        1. Thank you!

  12. Hello fellow programmers,

    I googled almost everywhere but cannot find the solution to my problem… I use Checkout Field Editor for WooCommerce plugin. I created couple new fields there ( pls see the picture here: https://prntscr.com/rzyiia ). I want these fields to display in shipping address box in email. I do not understand how to do this, which hook should I use to accomplish this? Here in this image I show where do they display instead ( https://prntscr.com/rzyn60 )

    Please if there any good folks who can help me?

    Thanks!

    1. Ask the plugin devs please

  13. On a new order email is there a way of displaying the Unit price rather than the total price for each item? So if someone ordered 5 pumpkins it shows the total price for all 5, what i also want to show it the price per pumpkin.

    1. Hi Patrick, 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!

  14. Hi Rodolfo!

    First of all; thanks for this awesome guide series.

    I’m trying to add some attachments (some pdf files that I created) to new order mails . But here’s the problem: I create PDF files when the “woocommerce_thankyou” hook triggered. But I guess the mails are sending before this. So “woocommerce_email_attachments” hook isn’t working for me. What can I do?

    1. Maybe you can use an earlier hook e.g. on order created?

  15. Hello,

    I have used your php snippets before with success, so thank your for that. However I can’t find something I am looking for. I would like to hide the e-mail address and phone number on orders in woocommerce for my vendors. So how can i remove this from the orders that are shown in the product vendors dashboard from woocommerce? I hope you can help me out, cause I have searched the internet, but wasn’t able to find anything.

    Look forward to hear from you.

    Kind regards,
    Tessa

    1. Tessa, 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!

  16. Hi, Rodolfo! Not entirely on topic but related: I’m trying to record in order notes when an order email has been sent. This is for admins so they know when an email went out. I can’t however see any hook linked to order email sending which I can use to trigger an order note being written. Am I missing something obvious or does Woo not offer the ability to hook into order email send action? Many thanks, Edith

    1. Hi Edith, 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!

  17. Your guides are great! I note your graphic uses the business-facing email as a demo, but do the same hooks apply to the customer-facing emails? Also, if so, does that mean inserting text via these hooks will insert it for both kinds of email? Right now, I’m just trying to affect customer-facing (order processing) emails.

  18. Hello

    Is it possible to remove the woocommerce_email_footer completely? I have tried to remove_action for the email footer but nothing I’ve tried has worked out. Any help would be greatly appreciated.

    Thanks

    1. Hello Dylan, 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!

  19. HI Rodolfo,
    Thank for the clear explanation videa’s. I’ve managed to add some content to my order processing email.
    Only adding when I try to add content in the footer using hook woocommerce_email_footer, it will display the content even under the footer instead of in the footer. What am I doing wrong?

    1. Hi Joren, thanks for your comment. It could be missing HTML/CSS or maybe Gmail in case you’re sending tests to yourself and it’s truncating duplicate content from previous identical emails. Let me know

  20. Thanks for this helpful article.
    I would like to know if it is possible to change the text in the email template without overriding the whole file?
    Thanks

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

  21. Thank you very much for this visual stuff. it helped me to understand it rapidly Bundle of thanks 🙂

    1. Thank you Rohi 🙂

  22. Hello Mr. Melogli

    I was hoping you might be able to help me:
    The image https://imgur.com/7WtDW8u displays an issue: “Undefined variable: email in /usr/www/mytowqvypx/wp-content/themes/towerlabels/woocommerce/emails/customer-order-status-email.php on line 65”

    Does that mean that the issue is limited to $email or every do_action(~); that contains it?

    Your assistance is most appreciated.
    Thank you and Kind Regards
    Luan

    1. Hey Luan 🙂 The issue is with your theme, you need to update it or switch to another one.

  23. Hi Rodolfo!
    I want erase the link “View my bookings →” of the email that receive the client.
    Just this link.
    I don´t know how do it.
    Can you help me?

    1. Hello Ulises- 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

  24. Hi Rodolfo, Fantastic guide – thank you!

    I have a question. Orders with both downloadable and shipped products show these in two distinct tables; are there hooks to only target the ‘downloadable’ items table? I’ve scoured the code but I feel like I’m missing something. Thanks for all your great content!

    1. Hey Lionel, thanks for your message! The only ones I could find are:

      woocommerce_email_downloads_column_1
      woocommerce_email_downloads_column_2
      // etc.
      

      Not sure if this helps 🙂

  25. dear Sir.
    please help me i want to add product weight at bottom of product title in woo-commerce emails.

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

  26. Can you guide me how to send cancel emails to customers, and let them know that there email are the cancel with the reason

    1. Hey Abdul, thanks so much for your comment! You can enable cancel order email notifications from the WooCommerce settings 🙂

  27. Hi, if we have to add text we have no option but to edit the template ( of course by copying the template into the child theme ) ? or is there a way to achieve the above with hooks?

    1. Hi Srikanth, thanks so much for your comment! It depends where you need to print it 🙂

  28. I have added som extra content with the use of “woocommerce_order_item_meta_end”

    But I see the message on all email templates.
    How to only show the content on the “Completed order” template ?

    1. Hey Simon, thanks for your comment! Section #4 of my video tutorial should help you achieve just that: https://businessbloomer.com/customize-emails-woocommerce/. Hope this helps

  29. Hi!

    Can I add email for new user notification?

    When a new customer sign in even if he did not make an order, I would like to get a notification email.
    (the recipient now is only the customer)
    Is that possible and how ?

    any suggestion will be great 😀
    thanks in advanced

    1. Hey Natalia, thanks for your comment! I believe you can add multiple email recipients to the same email, give it a go 🙂

  30. Hi, it is possible to make a hook, where the email that is sent to the customer after making a purchase (customer-on-hold-order.php.) Also reaches an email that I define?

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

  31. Hi Rodolfo is possible hide billing_company field from emails?

    1. Hey Mattia, 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. Thanks a lot for your understanding! ~R

  32. Hi,

    First I would like to say that you have a very important site.
    Thank you for all the tutorials.
    Few questions:
    ———————
    How can I:
    1. Add the regular price above the price (with strike through)?

    2. Add the total discount for the order in woocommerce_email_after_order_table?

    Thank you,

    Sam

    1. Hey Sam, thanks for your comment! I can’t help I’m afraid as it is custom work, however have you watched my tutorial yet: https://businessbloomer.com/customize-emails-woocommerce/?

  33. Hi Rodolfo

    I wanted to add a footer image to my e-mail template. Is this complicated?

    Thanks
    James

    1. Hey James thanks for your comment! No, it’s not complicated, as long as you understand minimal HTML and PHP. Take a look at this video tutorial, hopefully it can help together with my visual hook guide: businessbloomer.com/customize-emails-woocommerce/

  34. Hi, I have found it before but can’t find it anymore: where do we customize the code? (which file?)
    Thanks, Agnes

    1. Hey Agnes, thanks for your comment! You can place your customization in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/. Hope this helps!

  35. Hi Rodolfo, what a great info here in your awesome blog.

    I want to ask you if there is any way to hide/delete the prices row in this email

    thanks a lot

    1. Thank you so much David!!! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. Thanks a lot for your understanding! ~R

  36. I am new to all of this, but with your help I have been able to accomplish quite a few things. I am having a bit trouble of adding the product images to the email notifications. Is there a snippet or code for that function to work?

    1. Hello LaToya, thanks so much for your comment! Yes, this is possible, but unfortunately I don’t have a snippet for that 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

  37. Thanks for this, one of the easiest tutorials to follow that I have seen 🙂

    1. Awesome, thanks Stewart!

  38. Hi Rodolfo, i’m looking for a way to put, in the new order email, the product variation description (the one appears here when you choose a box type… (https://www.naranjascostadelsol.es/tienda-de-naranjas-online/naranjas-de-mesa-mandarinas-y-aguacates/).

    I spent a lot of hour to look for something valid but …no way…still searching… but now i fond your post here…and it seems i should work on woocommerce_order_item_meta_start… but i have no php skill…so do you have a snippet to do it?

    Thank you very much
    Angelo

    1. Angelo, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide you with 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

  39. Wow. That’s exactly what I was looking for! Thank you!
    Took me 20 seconds. 😀

    1. Awesome! Great to hear that Kevin 🙂

  40. HI,
    Is it possible to use hooks/filters to change the text which says: “Your order has been received and is now being processed. Your order details are shown below for your reference:” which appears at the top of the customer processing email?.

    1. Hey Andy, thanks for your comment! There is no filter to change that string, but I would recommend you try with this: https://businessbloomer.com/translate-single-string-woocommerce-wordpress. Let me know if it works!

      1. That looks great I will have to try it.
        I would also ideally like to change the text inside this:

        <?php printf( __( 'Thanks for creating an account on %s. Your username is %s‘, ‘woocommerce’ ), esc_html( $blogname ), esc_html( $user_login ) ); ?>

        which is sent in the new account email.

        I will want to keep the part of the string that dynamically displays the username so the complete new text will look like:

        Many thanks for creating an account with us, we’re delighted you’ve chosen to shop with us.

        Your username is:

        Kindest wishes
        Shop Name

        But will this part of the string:
        %s
        copy/translate over to the new string ok and ?

        1. Andy, with the translation snippet I referenced, you can totally translate “Thanks for creating an account on %s. Your username is %s” as a string. Only thing is that you have to maintain the order of the “%s”, so you will need to mention the shop name before the username.

          Otherwise, You will need to override the whole WooCommerce template.

          1. Brilliant, thanks!

  41. Hey Rodolfo, loved your webinar yesterday, thanks.

    I hope you can point me in the right direction as I can’t find the answer to this anywhere on your site but I’m sure you have probably covered it somewhere.

    On most customer emails there is a table that is headed:

    Product Quantity Price

    and contains rows showing Subtotal & Total.

    Where/how can I edit the table? I need to change the word Product to Event and if possible remove the Subtotal row as it isn’t relevant or required

    Thanks in advance

    1. Hi Rodolfo, just a quick update.

      I found I needed to change the email-order-details.php file for the Table Headings (simply changed the text in my child theme file)

      As for the SubTotal & Total – I removed a block of code from the bottom of the same file:

       <tfoot>
      	<?php
      		if ( $totals = $order->get_order_item_totals() ) {
      			$i = 0;
      			foreach ( $totals as $total ) {
      				$i++;
      				?><tr>
      					<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
      					<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
      				</tr><?php
      			}
      		}
      	?>
      </tfoot>

      Might help somebody!!

      1. Thanks Mark for updating us! I really hope you haven’t edited the plugin core files, but duplicated email-order-details.php into your child theme’s /woocommerce/emails folder 🙂

        Also, this might have been done without this duplication I believe (remember, duplicating templates should be done only when strictly necessary).

        Cheers and thanks again!

        R

        1. Don’t fret – it wasn’t the core file but in the child theme. Thanks for checking.

          1. Ah, awesome Mark 🙂 Glad about that! Thanks for following up.

  42. Hi,

    Thanks for this very detailed tutorial / guide.

    Is there any way we can add a custom image next to the text where “New customer order” is mentioned?

    Thanks.

    KoolPal

    1. Good question KoolPal!

      You can easily add content above or below, but doing it beside it’s pretty complex as there is no official hook. You might need to override the email-header.php in your child theme (not recommended), or maybe use the filter “woocommerce_mail_content”.

      Let me know if you find anything! I hope you can join us for the WooCommerce Emails Customization Class by the way 🙂

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 *