I want to add a notice section to order emails sent to admin if specific meta has a specific value (Umbrella Hole is "YES").
Code up till now:
function add_order_instruction_email( $order, $sent_to_admin, $plain_text, $email ) {
foreach( $order->get_items() as $item ){
$target_value = $item->get_meta('Umbrella Hole');
if ($target_value == "Yes") {
echo '<div style="background-color:antiquewhite;padding:5px;margin-bottom:10px;"><strong><span style="color:red;">Note:</span></strong> Umbrella Hole is present in the order. Please make sure velcro zipper split is requested from supplier too.</div>';
}
}
}
add_action( 'woocommerce_email_order_details', 'add_order_instruction_email', 10, 4 );
But it's not working. Anything I am doing wrong? Using latest versions of WordPress and WooCommerce.
References:
Get custom order item metadata in Woocommerce 3
How to get WooCommerce order details
WooCommerce: Show notice on new order email if specific payment method is used