Support » Plugin: WooCommerce » Add product category to order email?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi apreston48,

    There is an email template called “email-order-items.php” located at

    It’s used with the WC_Order:email_order_items_table() method called from this file: customer-completed-order.php

    If you override that template by copying it from
    /wp-content/themes/[YOUR THEME]/woocommerce/emails/email-order-items.php

    in your copy, you can add some code right about here:

    that would pull the terms (categories) for the product similar to what is happening here:

    Then you can display the categories.

    Thanks for the reply Daniel! I understand everything that is needed except the exact code to play in the copied email-order.items.php file. Also, sounds like there is code elsewhere that I need to add in order to display it.

    I’m not a developer, so I was curious if there was a simple way I could copy and paste the code where needed.

    Did you resolve this problem in the end as I need to do this too for one of my clients. I understand how to make the basic edits to the HTML / PHP but I don’t know what those edits should be.

    Can someone please post how to include the product category in the order email ?

    I did not get this resolved. I’m looking for the same how-to steps. I’m familiar with HTML / PHP too but not enough and was looking for the exact code and placement to get the product category to show on the order email.

    If anyone can help, that would be great. Thanks!

    Good day. You can achieve this by adding this code under line 19 of

    $terms = get_the_term_list( $_product->id, 'product_cat' );

    then under this line of code

    <td style="text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;">

    add this line

    <?php echo ''.$terms.': '; ?>

    voila. you got the code.

    Hi taongsagin

    I wonder if you could help me. I need to get the category into the email-order-items.php, I have tried adding the code above, but I can’t find the second lot of code (<td style=”text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;”>)
    in mine to replace. I have copied my code below.

    Thanks in advance for your help, really appreciate it.

    * Email Order Items (plain)
    * @author WooThemes
    * @package WooCommerce/Templates/Emails/Plain
    * @version 2.0.0

    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly

    global $woocommerce;

    foreach ( $items as $item ) :

    // Get/prep product data
    $_product = $order->get_product_from_item( $item );
    $item_meta = new WC_Order_Item_Meta( $item[‘item_meta’] );

    // Title, sku, qty, price
    echo apply_filters( ‘woocommerce_order_product_title’, $item[‘name’], $_product );
    echo $show_sku && $_product->get_sku() ? ‘ (#’ . $_product->get_sku() . ‘)’ : ”;

    // Variation
    echo $item_meta->meta ? “\n” . nl2br( $item_meta->display( true, true ) ) : ”;

    // Quantity
    echo “\n” . sprintf( __( ‘Quantity: %s’, ‘woocommerce’ ), $item[‘qty’] );

    // Cost
    echo “\n” . sprintf( __( ‘Cost: %s’, ‘woocommerce’ ), $order->get_formatted_line_subtotal( $item ) );

    // Download URLs
    if ( $show_download_links && $_product->exists() && $_product->is_downloadable() )
    echo “\n” . implode( “\n”, $order->get_downloadable_file_urls( $item[‘product_id’], $item[‘variation_id’], $item ) );

    // Note
    if ( $show_purchase_note && $purchase_note = get_post_meta( $_product->id, ‘_purchase_note’, true ) )
    echo “\n” . nl2br( $purchase_note );

    echo “\n\n”;


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add product category to order email?’ is closed to new replies.