I used WC Field factory to generate some custom fields including a textbox called "message_to_recipient." I want to pass this to the email that goes out.
In my functions.php, I am using this:
add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
function add_order_email_instructions( $order, $sent_to_admin ) {
$custom_message = get_post_meta( $order->ID, "message_to_recipient", true );
if ( ! $sent_to_admin ) {
echo '<h2>You received a gift Card from '.$order->billing_first_name .' '.$order->billing_last_name.'</h2>';
echo '<p><strong>Message:</strong> ' . $custom_message. '</p>';
}
The first echo, call to $order->billing_first_name
etc. works fine. But the second one doesn't.
having used WC Field Factory, am I simply not using the right name, or is this the wrong hook to grab the meta data from the order?