Remove bank details from WooCommerce order emails

This we were asked, if there is a way to remove only the bank details from a WooCommerce order email. Here is the exact question:

I would like to remove the bank account info that is displayed in the order-processing-email when chosen payment method is cash in advance. I know this is set though
woocommerce_email_before_order_table – action … could you help me with this

So I wrote this quick tutorial of how to do this. Here is the complete code for removing the bank details:

Lets break this down:

1. We need to remove the hook already in place to output the bank details: line 21 – 30. We take the gateway object and remove the hook, if the gateway is one of the available gateways. In this case the gateway is BACS or Bank Transfer.

2. We add our own action to output the bank instructions, but not the details: line 1 – 19. In this case we take the available gateways, check if the our gateway is available (line: 4-12), then we add the saved instructions only, much the same way they are added by the original hook(line: 14-19). Here is a place where you can add anything else you might want related to the bank details.

If you have any questions about this tutorial or you want to know how to do something else in WordPress or WooCommerce, just ask in the comments below.

Comments 17

  1. Hi there,
    I look at the tutorial and try it, but its not working, maybe I did something wrong. The bank detail, like instructions, account name, account number, bank name still showing at customer order on hold email.
    Is there any other method to remove it from the email?

    Anyway, the website not yet online, because of some things need to setup.

    Thank you.

    1. It worked, but what is weird it does not work anymore after today’s WordPress update. Code is still in child theme functions.php
      Any clue what’s wrong?

  2. Hey, great work! thank you very much!

    I got one more problem: when I add the code as described, the account details are gone. yet, I still find the instructions for the customer to transfer the money and that the order will be shipped once the money is transferred.

    How and where can I modify that?

    Thank you so much! Best, David

    1. Post
      Author

      Hi David,

      Refer to my other post, of removing the BACS details from the Thank You page. The process of removing the details from the email is basically the same but you are removing the other hook, like so: remove_action( 'woocommerce_email_before_order_table', array( $gateway, 'email_instructions' ), 10, 3 );

  3. Hi Vanbo,

    Awesome tutorial. It comes close to what I need. Maybe you can help?

    I offer COD as a payment gateway and each time I add a note to customer, the email they receive with that note also includes all payment info again. How can I hide that info for those emails?

    The payment info should still be shown on the thank you page and in the processing email.

    1. Post
      Author

      Hi Lodix,

      Just open the email template (customer-note.php) and remove all actions after the “For your reference, your order details are shown below” message. You can remove the message itself as it will not be necessary.

    1. Post
      Author
  4. Hi,
    thank you for your code, it works flawlessly.
    I’ve got problem: in my workflow, after the customer end his order, I send an email without the bank info (just an order received advice), then I add the shipping costs and send another email.
    Obviously with this email I have to send the bank infos also.
    How can I do?

    Many thanks.
    F.

    1. Post
      Author

      Hi Francesco,

      The bank info details are attached to the ‘woocommerce_email_before_order_table’ action. So in most cases when you send the second email, which needs to include the bank info, all you need to add is the following code:

      < ?php do_action( 'woocommerce_email_before_order_table', $order, true, false ); ?>

      Of course the “$order” needs to be the WC_Order object.

      Hope that helped.

      1. Hi Vanbo,

        I have the same issue but don`t know what do you mean by “Of course the “$order” needs to be the WC_Order object.”?

        Could you please help me?

        1. Post
          Author

          Hi Ashad,

          you get the WC_Order object by calling `$order = wc_get_order( $order_id );`. The $order_id needs to be the ID value of the order you are trying to send email for.

  5. Hi,

    This tutorial is exactly the one I’m looking for. But, since I’m not a programmer, could you please let me know where should I put the code above? In which .php file? Please advise. Many many thanks.

    1. Post
      Author

Leave a Reply

Your email address will not be published. Required fields are marked *