简体   繁体   English

从WooCommerce中的新订单电子邮件中删除银行帐户详细信息

[英]Remove bank account details from new order email in WooCommerce

Maybe you can give me a hand with this problem. 也许您可以帮我解决这个问题。 I need to remove the bank account information (BACS) from the new order email if the client select to pay with credit card and leave it if they select direct bank transfer. 如果客户选择使用信用卡付款,我需要从新订单电子邮件中删除银行帐户信息(BACS),如果他们选择直接银行转帐,则将其保留。 Right now the info appears in both emails. 现在,该信息同时出现在两封电子邮件中。 (Credit payment and direct transfer). (信用付款和直接转帐)。 I'm using this code: 我正在使用此代码:

// Add your own action for the bank instructions
 add_action( 'woocommerce_email_before_order_table', 
 'prefix_email_instructions', 9, 3 );
 function prefix_email_instructions( $order, $sent_to_admin, $plain_text = 
 false ) {
// Get the gateway object
$gateways           = WC_Payment_Gateways::instance();
$available_gateways = $gateways->get_available_payment_gateways();
$gateway            = isset( $available_gateways['bacs'] ) ? 
 $available_gateways['bacs'] : false;

// We won't do anything if the gateway is not available
if ( false == $gateway ) {
    return;
}

// Add only the email instructions
if ( ! $sent_to_admin && 'bacs' === $order->payment_method && $order- 
>has_status( 'on-hold' ) ) {
    if ( $gateway->instructions ) {
        echo wpautop( wptexturize( $gateway->instructions ) ) 
. PHP_EOL;
    }
}
}

// Remove the original bank details
add_action( 'init', 'prefix_remove_bank_details', 100 );
function prefix_remove_bank_details() {

// Do nothing, if WC_Payment_Gateways does not exist
if ( ! class_exists( 'WC_Payment_Gateways' ) ) {
    return;
}

// Get the gateways instance
$gateways           = WC_Payment_Gateways::instance();

// Get all available gateways, [id] => Object
$available_gateways = $gateways->get_available_payment_gateways();

if ( isset( $available_gateways['bacs'] ) ) {
    // If the gateway is available, remove the action hook
    remove_action( 'woocommerce_email_before_order_table', array( 
$available_gateways['bacs'], 'email_instructions' ), 10, 3 );
}
}

But the info is still there. 但是信息仍然存在。 Any idea how to solve this? 任何想法如何解决这个问题?

This line of code is enough for that. 这行代码就足够了。 It will unset the account details from the mail. 它将取消邮件中的帐户详细信息。

add_filter('woocommerce_bacs_accounts', '__return_false');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 WooCommerce 处理订单 email 通知中删除订单详细信息 - Remove order details from WooCommerce processing order email notification 从Woocommerce中已完成的订单电子邮件通知中删除订单明细表 - Remove order details table from completed order email notification in Woocommerce WooCommerce - 从订单详细信息和电子邮件中的产品标题中删除变化 - WooCommerce - Remove variation from product title in order details and email Woocommerce 在订单谢谢页面上删除银行帐号 - Woocommerce remove bank account number on order thank you page 如何在WooCommerce电子邮件中设置银行详细信息的样式? - How to stylize bank details in WooCommerce email? 如何在 WooCommerce 中的已完成订单 email 模板中添加新帐户信息 - How to add new account info on order completed email template in WooCommerce Woocommerce BACS在处理电子邮件中添加银行帐号 - Woocommerce BACS add bank account number on processing email Woocommerce我的帐户订单详细信息 - Woocommerce My-account order details 从 WooCommerce“暂停订单”和“新订单”电子邮件中删除订单编号 - Remove Order # from WooCommerce “Order on-hold” & “New Order” Emails 如何从 WooCommerce 中的新订单电子邮件中获取电子邮件收件人 - How to get email recipients from new order email in WooCommerce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM