从WooCommerce电子邮件中删除运输和计费



我想从管理员新订单中删除账单地址和送货地址.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;   
}

我知道如果我完全删除:

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

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

我试过了

unset($totals['billing_first_name']);

有很多变化,但它不起作用。

在此处输入图像描述

在下面的所有电子邮件模板中,执行操作钩子。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 );

要从邮件中删除帐单和运输详细信息,请在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 );

最新更新