WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Woocommerce 2.0, I need to print a custom field on the New Order email.

It is a meta/custom field each product has named "longsku" (which is normally hidden.)

This needs to be included in the email-order-items.php email template but I am not certain what syntax is necessary to print it.

For instance, variations are printed like so within the email template:

echo ($item_meta->meta) ? '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>' : '';

Does anyone have experience printing custom fields from products (not from actual checkout) in the email templates?

share|improve this question
up vote 2 down vote accepted

the longsku is regular wordpress post meta, so you can simply call that with get_post_meta.

get_post_meta takes three arguments:

  • post_id (which is already available in $_product)]
  • meta key ('longsku' in your case)
  • and a boolean to return a single string (true). if not set, it returns an array, but since the meta key is just a single value you can use true

this should do the trick for your longsku:

echo get_post_meta($_product->id,'longsku',true);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.