WooCommerce : Add custom Metabox to admin order page
<p>I am currently successfully adding a field to my WooCommerce product pages which is showing the value:</p>

<ul>
<li>in the cart (front end),</li>
<li>on checkout page (front end),</li>
<li>on order page (front end),</li>
<li>and in admin individual order page (back end). </li>
</ul>

<p>The problem: It isn't showing as a custom field in the admin order "custom fields" Metabox with the value inside it, but just as a text in the order page.</p>

<p>Here is my working code:</p>

<pre><code>// Add the field to the product
add_action('woocommerce_before_add_to_cart_button', 'my_custom_checkout_field');

function my_custom_checkout_field() {
    echo '&lt;div id="my_custom_checkout_field"&gt;&lt;h3&gt;'.__('My Field').'&lt;/h3&gt;';
    echo  '&lt;label&gt;fill in this field&lt;/label&gt; &lt;input type="text" name="my_field_name"&gt;';
    echo '&lt;/div&gt;';
}

// Store custom field
function save_my_custom_checkout_field( $cart_item_data, $product_id ) {
    if( isset( $_REQUEST['my_field_name'] ) ) {
        $cart_item_data[ 'my_field_name' ] = $_REQUEST['my_field_name'];
        /* below statement make sure every add to cart action as unique line item */
        $cart_item_data['unique_key'] = md5( microtime().rand() );
    }
    return $cart_item_data;
}
add_action( 'woocommerce_add_cart_item_data', 'save_my_custom_checkout_field', 10, 2 );

// Render meta on cart and checkout
function render_meta_on_cart_and_checkout( $cart_data, $cart_item = null ) {
    $custom_items = array();
    /* Woo 2.4.2 updates */
    if( !empty( $cart_data ) ) {
        $custom_items = $cart_data;
    }
    if( isset( $cart_item['my_field_name'] ) ) {
        $custom_items[] = array( "name" =&gt; 'My Field', "value" =&gt; $cart_item['my_field_name'] );
    }
    return $custom_items;
}
add_filter( 'woocommerce_get_item_data', 'render_meta_on_cart_and_checkout', 10, 2 );

// This is what I think needs changing?

function subscription_order_meta_handler( $item_id, $values, $cart_item_key ) {
    if( isset( $values['my_field_name'] ) ) {
        wc_add_order_item_meta( $item_id, "My Field", $values['my_field_name'] );
    }
}
add_action( 'woocommerce_add_order_item_meta', 'subscription_order_meta_handler', 1, 3 );
</code></pre>

<p>I think it is this last bit of the code that needs changing. It currently shows the text under the order item, so perhaps I need to adjust <code>wc_add_order_item_meta</code> to something else? </p>

<p>I've tried everything but it doesn't seem to work. I can get it to work when my field is on the checkout page but not when I pull it from the product page.</p>

<p>Perhaps I am missing a checkout process snippet?</p>