I'm trying to add order_comments field from woocommerce checkout page to new order admin email.
Here's how i did with other fields (it's for conditional shipping method):
add_action ('woocommerce_email_customer_details', 'custom_email_customer_details', 15, 4);
function custom_email_customer_details( $order, $sent_to_admin, $plain_text, $email ){
// Only for "New Order" email notification
if ( 'new_order' != $email->id ) return;
// Only "Flat Rate" Shipping Method
if ( $order->has_shipping_method('flat_rate') ) {
$order_id = $order->get_id(); // The Order ID
// Test output
echo '<table>';
echo '<tr>';
echo '<td>';
echo '<br><strong>'.__('Имя').':</strong> ' . get_post_meta( $order->id, '_billing_first_name', true );
echo '<br><strong>'.__('Фамилия').':</strong> ' . get_post_meta( $order->id, '_billing_last_name', true );
echo '<br><strong>'.__('Метод доставки: Доставка курьером по Киеву').'</strong> ';
echo '<br><strong>'.__('Улица').':</strong> ' . get_post_meta( $order->id, '_shipping_address_1', true );
echo '<br><strong>'.__('Дом').':</strong> ' . get_post_meta( $order->id, '_shipping_address_2', true );
echo '<br><strong>'.__('Подъезд').':</strong> ' . get_post_meta( $order->id, '_shipping_city', true ) ;
echo '<br><strong>'.__('Этаж').':</strong> ' . get_post_meta( $order->id, '_shipping_state', true ) ;
echo '<br><strong>'.__('Квартира').':</strong> ' . get_post_meta( $order->id, '_shipping_postcode', true ) ;
echo '<br><strong>'.__('Время доставки').':</strong> ' . get_post_meta( $order->id, 'Время доставки', true ) ;
echo '<br><strong>'.__('Комментарий покупателя').':</strong> ' . ( $order->id, 'order_comments', true ) ;
echo '</td>';
echo '</tr>';
echo '</table>';
$mailer = WC()->mailer();
remove_action( 'woocommerce_email_customer_details', array( $mailer, 'email_addresses' ), 20, 4 );
}
Adding next line doesn't help:
echo '<br><strong>'.__('Order notes').':</strong> ' . ( $order->id, '_order_comments', true ) ;
So what am I doing wrong? Thanks in advance