1
votes

I'm trying to add some labels after Woocommerce order email items.

Ex- we can do that on cart by using this filer

add_filter( 'woocommerce_cart_item_name', array( $this, 'wc_esd_show_date_cart_page' ), 10, 2 );

above call wc_esd_show_date_cart_page() function and show its data after item name

I want to do the same for order email items, anyone know there have some filter for it, or another way to do this.

enter image description here

1

1 Answers

1
votes

The very similar hook for orders and email notifications is woocommerce_order_item_name filter hook.

But the function arguments are quiet different and you might need to make some changes to your existing function code.

The following will target only email notifications

add_filter( 'woocommerce_order_item_name', 'wc_esd_show_date_on_order', 10, 3 );
function wc_esd_show_date_on_order( $item_name, $item, $is_visible ) {
    // Only for email notifications
    if( is_wc_endpoint_url() ) 
        return $item_name;

    // ---------------- Your code start below ---------------- //
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.