A lot of the time, the default WooCommerce product editor doesn’t give the user enough flexibility in assigning custom meta. If you’re using WooCommerce to sell events for example, you might want to install Advanced Custom Fields (ACF) to assign important attributes to products like the start time, venue, and organiser. In the emails, you may then wish to output this meta data under the relevant product name. This short snippet gives you the ability to show product meta (e.g. custom field data) under the product name in the WooCommerce emails. If you do have more than one custom field, simply assign another variable and replace the variable name and custom field name declaration.
/**
* Snippet Name: Show product meta (for example ACF field data) under the product names in the WooCommerce emails.
* Snippet Author: ecommercehints.com
*/
add_action( 'woocommerce_order_item_meta_start', 'ecommercehints_order_item_meta_start', 10, 4 );
function ecommercehints_order_item_meta_start($item_id, $item, $order, $plain_text) {
$the_order_id = $order->get_id();
$order_items = $order->get_items();
$custom_field_variable = get_post_meta( $item->get_product_id(), 'custom_field_name', true ); // Change custom_field_name to the name of your custom product meta field
echo '' . $custom_field_variable . '
';
}