WooCommerce - excelling eCommerce
Add product category to order email? (7 posts)

  1. apreston48
    Posted 2 years ago #

    I'd like to add the Product Category name to the emails sent to the customer (Order Received) - preferably in the order table next to the Product name. Can I do that?



  2. Daniel Espinoza
    Posted 2 years ago #

    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.

  3. apreston48
    Posted 2 years ago #

    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.

  4. gazado
    Posted 2 years ago #

    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 ?

  5. apreston48
    Posted 2 years ago #

    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!

  6. taongsaging
    Posted 1 year ago #

    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.

  7. jamlaw
    Posted 1 year ago #

    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";


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic