首页 > 解决方案 > 在 WooCommerce 电子邮件中的客户详细信息之后移动 BACS 银行详细信息

问题描述

我如何在 Woocommerce 邮件模板“customer-processing-order.php”中移动 BACS 银行详细信息。

我想从中删除/移动它

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

而它之后

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

但是只有银行详细信息而不是 order_details 操作中的其他内容?

标签: phpwordpresswoocommerceemail-notificationspayment-method

解决方案


无法针对特定的电子邮件通知...现在要在客户详细信息之后从 Woocommerce 电子邮件通知中移动 BACS 银行详细信息,请使用以下命令:

add_action( 'init', 'move_bacs_bank_details', 1000 );
function move_bacs_bank_details() {
    if ( class_exists( 'WC_Payment_Gateways' ) ) {
        $gateways = WC_Payment_Gateways::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 );
            add_action( 'woocommerce_email_customer_details', array( $available_gateways['bacs'], 'email_instructions' ), 30, 3 );
        }
    }
}

代码位于活动子主题(或活动主题)的 functions.php 文件中。测试和工作。


推荐阅读