2017-08-11 127 views
0

我想从admin-new-order.php中删除帐单地址和送货地址。我的主题已经有了它的重复。我能够删除电子邮件和电话号码,但我不能删除帐单和运费。从woocommerce电子邮件中删除运费和帐单

要删除的电子邮件和电话我这样做是

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']); 

和这个这么多的变化,但它不工作。

enter image description here

+0

请张贴在动作的所有变量的var_dump()。 – DrDamnit

+0

它的帖子太长了。它只允许在这里有600个字符:/ – Franky

+0

使用https://giat.github.com或paatebin.com – DrDamnit

回答

0

在你有以下的所有电子邮件模板做动作钩。 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); 
+0

我试着添加这个,它给了我一个与其他东西相冲突的错误。所以它不可能通过“unset()”删除运输和结算,就像我删除了电子邮件和电话一样? – Franky

+0

@Franky这段代码工作正常。请提供错误屏幕截图或更多详细信息。 –

+0

或者即使我只是将“客户注释”添加到“元”部分,那也能解决我的问题。 – Franky

相关问题