title: How to print field created by 'WooCommerce Custom Order Data' Plugin to email
body: <p>I installed WooCommerce Custom Order Data PlugIn to create a custom field after checkout is completed. In a custom plugin I use the woocomerce_thankyou-hook to collect some data from the order and save it as a string to $order->custom->officer_text.</p>
  
  <p>I need to print that custom data to the admin-new-order-mail, but I don't know how to do that.</p>
  
  <pre><code>echo $order-&gt;custom-&gt;officer_text
  </code></pre>
  
  <p>in admin-new-order-mail.php doesn't work.</p>
  
  <p>I can print_r the data on the thank you-page, so I know, it's there. But no luck in the email-template.</p>
  
  <p>How do I get it to work?</p>
  
  <p>Edit:</p>
  
  <p>I forgot to post the code of my custom plugin.</p>
  
  <pre><code>if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    global $woocommerce;
    // Action after order is submitted
    add_action('woocommerce_thankyou', 'woocommerce_officer_data');
    // function to populate a custom field in $order
    function woocommerce_officer_data($order_id) {
      $order = new WC_Order( $order_id );
      // create custom field
      WC_CustomOrderData::extend($order);
      $order-&gt;custom-&gt;officer_text = '';
      $officer = '';
      // get date and format
      $date = DateTime::createFromFormat('Y-m-d H:i:s', $order-&gt;order_date);
      $orderdate = $date-&gt;format('d.m.Y');
      $ordertime = $date-&gt;format('H:i:s');
      $officer .= '##Officer-START##&lt;br&gt;Datum:' . $orderdate . '&lt;br&gt;Zeit:' . $ordertime . '&lt;br&gt;';
      $officer .= $order_id . '|' . $order_id . '|' . $order-&gt;billing_first_name . '|' . $order-&gt;billing_last_name . '|';
      $officer .= $order-&gt;billing_country . '|' . $order-&gt;billing_postcode . '|'  . $order-&gt;billing_city . '|' ;
      $officer .= $order-&gt;shipping_address_1 . '|' . $order-&gt;billing_email . '|' . $order-&gt;billing_phone . '|' ;
      $order-&gt;custom-&gt;officer_text = $officer;
      $order-&gt;custom-&gt;save();
      echo $order-&gt;custom-&gt;officer_text;
    }
  }
  </code></pre>
  
  <p>The field is printed right after the ul.order_details.bacs_details</p>
  
  <p>But if I print_r($order) on thankyou.php, the custom data is not there, .</p>
  
  <p>print_r($order->custom) in the plugin gives me this:</p>
  
  <pre><code>WC_CustomOrderData Object
    (
      [order_id:WC_CustomOrderData:private] =&gt; 241
      [fields:WC_CustomOrderData:private] =&gt; Array
        (
         [officer_text] =&gt; ##Officer-START##
           Datum:09.10.2013
           Zeit:12:00:38
           241|241|Peter|Petersen|DE|11111|Xtown|Ystreet 53|foo@example.de||01xx 654 xxx xx|
         )
  
     )
  </code></pre>
  
  <p>I'm happy, I got so far, because I'm not a real coder, but I have no idea, how to control the output of my first little plugin. So, if someone could show me a 'best practise' solution, it would be great.</p>