2
votes

I am using a function in my functions.php file to display the purchase note for products in Woocommerce customer email. It looks like this:

function sww_add_note_woocommerce_emails( $output, $order ) {

    // set a flag so we don't recursively call this filter
    static $run = 0;

    // if we've already run this filter, bail out
    if ( $run ) {
        return $output;
    }

    $args = array(
        'show_purchase_note'    => true,
    );

    // increment our flag so we don't run again
    $run++;

    // if first run, give WooComm our updated table
    return wc_get_email_order_items( $order, $args );
}
add_filter( 'wc_get_email_order_items', 'sww_add_note_woocommerce_emails', 10, 2 );

This works perfectly for the email that the customer receives, but I also want it to display the notes in the 'new order' email that admin receives.

They both use the same order table so I'm not sure why it isn't working.

1

1 Answers

1
votes

I didn't find a hook for wc_get_email_order_items but a function with some other hooks. Try instead:

add_filter( 'woocommerce_email_order_items_args', 'display_customer_note_in_all_emails', 10, 1 );
function display_customer_note_in_all_emails( $args ) {
    $args['show_purchase_note'] = true;

    return $args;
} 

Code goes in function.php file of your active child theme (or active theme). It should works.