sHamann
sHamann

Reputation: 799

Removing BACS instructions from email notiications in WooCommerce

On my WooCommerce web shop I have enabled the payment getaway "Direct bank transfer".

In Woocommerce --> Settings --> Checkout --> BACS there is a field called "instruction". This textfield is added to the thank you page, which is good.
But it's also added to the costumer-order-completed email, which I dont want.

I already tried to understand the files which are responsible for email notification, but I have no clue to avoid the display for this "instructions" text.

How can I remove "instructions" text for BACS payment gateway in email notification?

Upvotes: 2

Views: 3281

Answers (2)

LoicTheAztec
LoicTheAztec

Reputation: 253867

Using a custom function hooked in woocommerce_email_order_details action hook that will remove the Direct Bank Transfer (BACS) instructions from email notifications:

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['bacs'] ) )
        remove_action( 'woocommerce_email_before_order_table', array( $available_gateways['bacs'], 'email_instructions' ), 10, 3 );
}, 1 );

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This code is tested and works for WooCommerce version 2.6.x and 3+

Upvotes: 4

You can solved this in the line 38

do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );

File: https://github.com/woocommerce/woocommerce/blob/master/templates/emails/customer-completed-order.php

Upvotes: 0

Related Questions