Conditional Customization with Actions/Filters

The final and most effective approach to customizing emails is to work with WooCommerce custom code. This obviously requires a high-level of expertise in PHP. The good news is that the process is straightforward because the original WooCommerce layouts are still in use. The process involves changing portions of the content.

Filter Functions

Actions Functions

Activation/Deactivation/Uninstall Functions

For this example, I will add some helpful payment instructions to the email, based on the checkout payment type used.

To start, add the following to the theme’s functions.php:

add_action( 'woocommerce_before_email_order', 'add_order_instruction_email', 10, 2 );
 
function add_order_instruction_email( $order, $sent_to_admin ) {
  
  if ( ! $sent_to_admin ) {
 
    if ( 'cod' == $order->payment_method ) {
      // cash on delivery method
      echo '<p><strong>Instructions:</strong> Full payment is due immediately upon delivery: <em>cash only, no exceptions</em>.</p>';
    } else {
      // other methods (ie credit card)
      echo '<p><strong>Instructions:</strong> Please look for "Madrigal Electromotive GmbH" on your next credit card statement.</p>';
    }
  }
}


Source: https://www.cloudways.com/blog/how-to-customize-woocommerce-order-emails/