I tried the following code that is displaying a message to all those customers who should receive a customer_processing_order
and customer_completed_order
This can be done iterating through order shipping items, this way:
add_action( 'woocommerce_email_order_details', 'my_completed_order_email_instructions', 10, 4 );
function my_completed_order_email_instructions( $order, $sent_to_admin, $plain_text, $email ) {
// Only for processing and completed email notifications to customer
if( ! ( 'customer_processing_order' == $email->id || 'customer_completed_order' == $email->id ) ) return;
foreach( $order->get_items('shipping') as $shipping_item ){
$shipping_rate_id = $shipping_item->get_method_id();
$method_array = explode(':', $shipping_rate_id );
$shipping_method_id = reset($method_array);
// Display a custom text for local pickup shipping method only
if( 'local_pickup' == $shipping_method_id ){
echo '<p><strong>Ritiro in sede</strong></p>';
break;
}
}
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.