从 woocommerce 电子邮件中删除运费和账单

0 php wordpress email-templates woocommerce

我想从 admin-new-order.php 中删除帐单地址和送货地址。我的主题中已经有它的副本。我可以删除电子邮件和电话号码,但无法删除账单和运费。

为了删除电子邮件和电话,我这样做了

    add_filter( 'woocommerce_email_customer_details_fields', 'custom_woocommerce_email_customer_details_fields' );    
function custom_woocommerce_email_customer_details_fields( $totals ) {
      unset( 
             $totals['billing_email'],
             $totals['billing_phone']
            );
           return $totals;   
         }
Run Code Online (Sandbox Code Playgroud)

我知道如果我完全删除:

 do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
Run Code Online (Sandbox Code Playgroud)

它会删除所有内容,但我不能这样做,因为我需要在那里显示的注释和交付时间(来自插件)。如果我删除整个内容,那么它就会删除所有内容。

我试过了

unset($totals['billing_first_name']);
Run Code Online (Sandbox Code Playgroud)

虽然有很多变体,但它不起作用。

在此输入图像描述

Ank*_*nia 5

在下面的所有电子邮件模板中,执行操作挂钩。WC_Emails::email_address() 此功能代码用于在邮件中添加帐单和运输详细信息。

/**
 * @hooked WC_Emails::customer_details() Shows customer details
 * @hooked WC_Emails::email_address() Shows email address
 */
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
Run Code Online (Sandbox Code Playgroud)

要从邮件中删除账单和运输详细信息,请将以下功能放入您的function.php文件中

function removing_customer_details_in_emails( $order, $sent_to_admin, $plain_text, $email ){
    $wmail = WC()->mailer();
    remove_action( 'woocommerce_email_customer_details', array( $wmail, 'email_addresses' ), 20, 3 );
}
add_action( 'woocommerce_email_customer_details', 'removing_customer_details_in_emails', 5, 4 );
Run Code Online (Sandbox Code Playgroud)