【问题标题】:Removing BACS instructions from email notiications in WooCommerce从 WooCommerce 中的电子邮件通知中删除 BACS 指令
【发布时间】:2018-01-12 22:52:38
【问题描述】:

在我的 WooCommerce 网上商店中,我启用了付款方式“直接银行转帐”

Woocommerce --> Settings --> Checkout --> BACS 中有一个名为“指令”的字段。此文本字段已添加到 thank you 页面,这很好。
但它也被添加到客户订单完成电子邮件中,这是我不想要的。

我已经尝试了解负责电子邮件通知的 文件,但我不知道如何避免显示此“说明”文本。

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

【问题讨论】:

    标签: php php wordpress woocommerce payment-gateway email-notifications


    【解决方案1】:

    使用挂在 woocommerce_email_order_details 操作挂钩中的自定义函数,该函数将从电子邮件通知中删除直接银行转账 (BACS) 指令

    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+

    【讨论】:

    • 干得不错,你!
    【解决方案2】:

    你可以在第 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

    【讨论】:

    • 我提交了//do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );这行,但它对电子邮件没有影响。我做错了吗?
    猜你喜欢
    • 2019-03-17
    • 2019-04-18
    • 1970-01-01
    • 2017-12-15
    • 2018-05-15
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多