首页 文章

从WooCommerce中的电子邮件通知中删除BACS指令

提问于
浏览
1

在我的WooCommerce网上商店,我启用了付款方式 "Direct bank transfer" .

Woocommerce - > Settings - > Checkout - > BACS 中有一个名为 "instruction" 的字段 . 此文本字段已添加到 thank you 页面,这很好 .
但它也被添加到 costumer-order-completed email ,我不想要 .

我已经尝试了解负责电子邮件通知的php文件,但我无法避免显示此"instructions"文本 .

如何在电子邮件通知中删除BACS支付网关的“说明”文本?

2 回答

  • 0

    你可以在第38行解决这个问题

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

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

  • 2

    使用挂钩在woocommerce_email_order_details动作钩子中的自定义函数将删除 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 );
    

    代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中 .

    此代码经过测试,适用于WooCommerce版本2.6.x和3

相关问题