I've been trying to remove the payment instructions that you specify in "Payment Instructions" for COD payments for the invoice emails. That information automatically gets included into all order emails sent by Woocommerce.
So I did some research and eventually found this post here on Stackoverflow that apprently solved someone elses problem."Removing BACS instructions from email notiications in WooCommerce" Removing BACS instructions from email notiications in WooCommerce.
Here's the specific code (modified to work with COD payments):
add_action( 'woocommerce_email_before_order_table', function(){
if ( ! class_exists( 'WC_Payment_Gateways' ) ) return;
$gateways = WC_Payment_Gateways::instance(); // gateway instance
$available_gateways = $gateways->get_available_payment_gateways();
if ( isset( $available_gateways['cod'] ) )
remove_action( 'woocommerce_email_before_order_table', array( $available_gateways['cod'], 'email_instructions' ), 10, 3 );
}, 1 );
Unfortunately the code provided does not work for me.
What happens is
1. I put that code in my functions.php file in my child theme folder and save.
2. I open up an individual order in the woocommerce order page and choose Order Actions -> Email invoice/order details to customer.
Unfortunately, the result is that the order page loads part of the email template in the window instead, and no email is sent out. I have to press backwards in the browser to get back to the order page.
I contacted Woocommerce support forums, and the person who responded to me had also found that code, modified it to work with cod, and said it worked. However, when I asked her if she could try it with the same steps I did to see if that works, I got no further response. I'm hoping someone here can test it with the same steps that I did to see if it works or not. If it does, then it's obviously something with my specific site that makes it not work.
I have also seen the "gettext()" solution as specified in this thread: Remove Cash On Delivery Instructions From WooCommerce Emails but I would like to, if possible, not have to use that.
I have Woocommerce version 3.6.2 and have tested this code with 2 other earlier versions as well to no avail. Hoping I can get some help or insight here as to why this is not working. I'm using other woocommerce hooks with no problems.
Thanks.