8

I would like to output the Product Short Description beneath the product name inside the order items table inside WooCommerce emails. I think I know where to place code inside the email template file, but I don't know how to access the description of an item. I don't see any mechanism to retrieve it. What do I need to do to echo out the field?

Thanks in advance!

closed as off-topic by Mayeenul Islam, Pieter Goosen, TheDeadMedic, Howdy_McGee, Mark Kaplun Apr 25 '15 at 6:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

15

I finally tried using var_dump() on $item and $_product, which are both used in the email-order-items.php template. $_product revealed a post object, which itself has a post_excerpt property, which looks like it holds the contents of the "Product Short Description" from the WooCommerce product form.

So, to add the description beneath the item name, I added this to my code:

echo '<br/>' . $_product->post->post_excerpt;

Voilà! The short description appears in the email!

Hope this helps someone else! Took me a couple hours of frustration to get it.

  • 3
    If you are inside the loop, you can use <?php the_excerpt(); ?> – Pablo S G Pacheco Apr 17 '17 at 19:29

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