How to add custom fields to order emails

By default custom fields don’t appear in invoices that are sent to customers. If you want the custom fields to appear beneath each variation product on the invoice, you can add this code snippet to the functions.php of the child theme or Code Snippet plugin.

 * Iconic Custom Fields for Variations: Add custom fields data to email.
 * @param int                   $item_id
 * @param WC_Order_Item_Product $item
 * @param WC_Order              $order
 * @param bool                  $plain_text
 * @return void
function iconic_cffv_add_feilds_data_to_emails( $item_id, $item, $order, $plain_text ) {
	$product      = $item->get_product();
	$product_type = $product->get_type();

	if ( 'variation' !== $product_type ) {

	$parent_id    = $product->get_parent_id();
	$variation_id = $product->get_id();

	$custom_fields_data = Iconic_CFFV_Fields::get_product_fields_data( $variation_id );

	foreach ( $custom_fields_data as $data ) {
		printf( '<strong>%s</strong>: %s <br>', esc_html( $data['data']['label'] ), esc_html( $data['value'] ) );
add_action( 'woocommerce_order_item_meta_end', 'iconic_cffv_add_feilds_data_to_emails', 10, 4 );

Are you using WooCommerce Custom Fields for Variations yet?

Start your 14-day free trial right now and get instant access to the features described in this article.

or learn more

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.

WooCommerce Custom Fields for Variations by Iconic

WooCommerce Custom Fields for Variations

Not got the plugin yet? Get instant access right now, free for 14 days.

or learn more

Still need help?

If you haven't found what you're looking for in our documentation, please contact support.

Get Support