My products have a custom field called depot. I need to display this field only in admin mail notifications, not to the customer order recap or customer mail notifications.
I use this code to retrieve the custom field in email notifications :
add_action( 'woocommerce_email_order_meta', 'add_depot', 10, 3 );
function add_depot( $order, $sent_to_admin, $plain_text ){
$items = $order->get_items();
foreach ( $items as $item ){
$depot = $item->get_meta('depot');
$item['name'] = 'Dépôt: ' . $depot . $item['name'];
}
}
At the moment, it displays the field only in customer emails and not in admin emails as I would like. I think I need to use $sent_to_admin but I'm not sure how.
Thank you.