Emails

WooCommerce Show Product Meta Under Product Name In Emails

WooCommerce email showing custom product meta field data under the product names

Pre-Requisites

You need a way of facilitating adding product meta prior to showing it in emails. This could be through Advanced Custom Fields (ACF) assigned to the products post type.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

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 metadata 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 '<p>' . $custom_field_variable . '</p>';
}

Snippet Benefits

  • Output important custom product fields data under the product names in the WooCommerce emails.
  • Give customers more clarity around their products.
  • Save money by editing the emails yourself instead of using an expensive email customisation plugin.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER