Add a note under the product details to WooCommerce order emails.
This is similar to my post about adding info to WooCommerce order emails but it adds a product specific note directly under the product name and variation info.
The other post showed the basic do_action() layout of order emails:
The other post used the ‘woocommerce_email_order_details‘ action to put the note above the list of ordered items.
Here I will use the ‘woocommerce_order_item_meta_end‘ action to examine an individual product and determine whether a note should be displayed. While there is a ‘woocommerce_order_item_meta_start‘ action that is run before variation details are displayed, I chose to add my note after those details.
The other code examined each item in the cart. Here the ‘woocommerce_order_item_meta_end‘ action passes the item object to the calling function so it allows us quickly examine the individual product.
As a demonstration I have kept the code simple – it adds a hard coded note for variable products. This could be expanded to have different notes for each product – just add an array of product IDs with notes and look them up in the function.
Here is the simple code:
And the result is directly under the product in question:
Note: This code also displays the text on the Order Received page.