Add Order Notes To WooCommerce Completed Order Email

Each you perform an action regarding a WooCommerce order, a note is created. This is the best way to track every single action made on an order, and of course that’s very useful when your team needs to get the full order history. That can be also useful to share this order notes history to your customer. The best way to do it is to add the notes in the completed order email. What you need to know is that these notes are WordPress comments, so any WordPress comments related function can be used, and you can retrieve any data using the comment object.

Here what you can see in the administration, on the order edit page:

admin-order-notes

To display all these notes in the order completed email, simply add the following code to the customer-completed-order.php file. Please note that this file is a template; basically a custom template allows you to override WooCommerce default files and use your own custom files instead. Here is a quick tutorial that will explain you how to create your custom templates: http://docs.woothemes.com/document/template-structure/

So, create a folder called woocommerce in your theme folder. In this folder, create a new folder called emails, and in this folder duplicate the customer-completed-order.php from wp-content/plugins/woocommerce/templates/emails. And add this snippet at line 51:

Here is the result in the email:

email-order-notes

22 responses to “Add Order Notes To WooCommerce Completed Order Email”

  1. […] Check out How to remove “From: $$” from your product catalog by Patrick Rauland or How to Add Order Notes To WooCommerce Completed Order Email by Remi Corson. WooNinja Gerhard Potgieter also released a free plugin to refill stock for refunded […]

  2. bocce

    Hiya Remi, what are your thoughts on the following?

    In woocommerce you can add purchase notes – which is displayed on both checkout + in confirmation email.

    If the “groups plugin” is installed and activated, the purchase notes are no longer sent in the confirmation email.

    Do you have any thoughts on what code could be entered into the email template to ensure purchase notes continue to be sent in the confirmation email?

  3. atejena

    When I plug this into the code of my template, I only get the h2 header (Order Notes) but the rest of the info isn’t there. I’m using WP 3.6.1 any thoughts? HELP! :(

    1. what’s the exact code you used?

      1. atejena

        ‘approve’,
        ‘post_id’ => $order->id
        );
        $comments = get_comments($args);
        foreach($comments as $comment) :
        echo $comment->comment_content . ”;
        endforeach;
        ?>

        1. atejena

          ‘approve’,
          ‘post_id’ => $order->id
          );
          $comments = get_comments($args);
          foreach($comments as $comment) :
          echo $comment->comment_content . ”;
          endforeach;
          ?>

  4. atejena

    the code is Exactly what you posted. For some reason I can’t post the code here because it will only show part of it.

    Alex

  5. atejena

    Hey Rem. I sent a message last week about not being able to see the info on the order confirm.. Were you able to figure it out?

  6. lydiany

    Hey Remi,

    This post is very helpful! Is there any way to edit the code so only the customer notes are added to the email?

    Thanks!

    Lydia

    1. the only way to do it is to check the “comment_author_email” and see if if it matches the purchaser’s email from the $order object.

  7. kainer

    Remy, I have a question regarding one of the images you used here. In your email to the customer, in the table, there is NO tax behind your listed product. Why is that? Any idea where to option to fin to set it to be shown? I ask, becaue I have two shops. One is showing taxes behind the productname in this email-table, the other won’t. And all settings seems to be the same in both shops. Maybe you can help me where to find the option to show taxes behind products in the table in the customer email they get when they ordered. Here is a screenshot showing what information I mean.http://imgur.com/ABwTAok

  8. Nickylew

    How about a snippet for adding the products original price into the mail next to the total price of the product(s).

    So it would go:
    Product | Quantity | Unit Price | Total Price ??

    Is it possible to do something like that in the new order email?

    Man Thanks

    1. yes you can do that with custom templates pretty easily and retrieve all details from the $order object

  9. anfeloga

    Hi

    Is it possible to send just the last note? I don’t want my customers know how much stock do I have after they bougth and just want to add a custom note “tracking number” in order to let them know their tracking number order.

    Thanks!

    1. pmaridnah

      Were you ever able to figure this out Anfeloga? We are running into the same issue. Don’t want the customer to see all notes. Our shipment processor adds a note with tracking information, but we only want to send the last note, not all of them with payment notes, stock, etc.

      Any ideas? Thanks!

  10. rp

    Hi Remi,

    The code works as expected for me when I am completing the order or re-sending the completed e-mail via the woocommerce admin.

    However, I am finding that it does not work when I call via the API and set the order status to completed. Basically no comments are making its way down to the e-mail view. Have any thoughts on why they might not be accessible and how to work around?

    Thanks – Ryan

  11. Ishmael

    woocommerce-shipstation/includes/api-requests/class-wc-shipstation-api-shipnotify.php

    Starting at Line 142:

    $order->add_order_note( $order_note, $is_customer_note = 1 );

    // Update order status
    if ( $order_shipped ) {
    $order->update_status( WC_ShipStation_Integration::$shipped_status );
    $this->log( sprintf( __( “Updated order %s to status %s”, ‘woocommerce-shipstation’ ), $order->id, WC_ShipStation_Integration::$shipped_status ) );
    }

    The order completed email is sent out when the order status has been set to completed, great. However, it seems that none of the order notes are available.

    Added the order notes to email template per Remi’s post: http://www.remicorson.com/add-order-notes-to-woocommerce-completed-order-email/

    Not sure why this is happening. Maybe because the woocommerce-shipstation plug-in doesn’t load the WordPress comments when the email is being sent. If I manually set the order status to Completed, the order notes are included in the email.

    [ MY FIX ]
    The only way for me to be able to get the order note added at Line 142 was to store it in $GLOBALS:

    $order->add_order_note( $order_note, $is_customer_note = 1 );

    // Update order status
    if ( $order_shipped ) {
    $GLOBALS[‘SS_order_note_on_shipped’] = $order_note;

    }

    Now in /wp-content/themes/mytheme/woocommerce/emails/customer-completed-order.php I can access $GLOBALS[‘SS_order_note_on_shipped’] to get the value of the note when the order completed email is sent out.

    Hoping to find a solution that doesn’t require that I modify the plug-in code though.

    Thanks for everything!

  12. Remi,
    when a customer makes a credit card purchase no transaction information is automatically posted into the order notes section. When another customer pays with Paypal I get all the data automatically from Paypal. Is there an easy explanation why this is happening and how can it be fixed?

  13. digamber

    Hello Remi,
    Am i doing something wrong or is the code no longer working on the latest version of WooCommerce(2.4.12) ?
    I had to modify the code a bit to get it working, here’s my implementation.

    $args = array(
    'post_id' => $post->ID,
    'orderby' => 'comment_ID',
    'order' => 'DESC',
    'approve' => 'approve',
    'type' => 'order_note'
    );

    remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );

    $notes = get_comments( $args );

    add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );

    1. I tested with the latest 2.5 beta and it still works fine. It would be better to embed note into a function and load it via a hook, but the code provided here still works.

  14. venky4c6

    Hi Remi Good Evening.. when the user,admin received the email from completed order,processing order .. i receive the order id before order table.. i want to display the boooking id ,instead of the order id… how can i do that pls help me

    thanks

  15. zorem

    Hi Remi,
    In the past, the customer note for the order was in the order meta, in the new order email:

    and the customer details section showed the email / phone number.
    Now there was a change in the last woocommerce version – from the change log:
    Dev – Template – Added template files for the customer details list in emails. emails/email-customer-details.php
    and now the customer details show the customer order note as well.
    Is there a way to separate the order notes form the email/phone number?
    I am sending order notification emails to drop shippers, I am not interested that they will receive the email / phone of the customer but I do want them to receive the customer order note.

Leave a Reply