Removing BACS instructions from email notiications in WooCommerce

三世轮回 提交于 2020-01-01 19:24:51

问题


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 php 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?


回答1:


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+




回答2:


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



来源:https://stackoverflow.com/questions/45516304/removing-bacs-instructions-from-email-notiications-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!