【问题标题】:remove shipping and billing from woocommerce email从 woocommerce 电子邮件中删除运输和计费
【发布时间】:2017-08-11 01:44:14
【问题描述】:

我想从 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;   
         }

我知道如果我完全删除:

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

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

我试过了

unset($totals['billing_first_name']);

还有这么多变体,但它不起作用。

enter image description here

【问题讨论】:

标签: php wordpress woocommerce email-templates


【解决方案1】:

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

【讨论】:

  • 我尝试添加此内容,但它给了我一个与其他内容冲突的错误。所以它不可能像我删除电子邮件和电话一样使用“unset()”删除运输和计费?
  • @Franky 此代码运行良好。请提供错误屏幕截图或更多详细信息。
  • 或者即使我可以将“客户备注”添加到“元”部分,也可以解决我的问题。
  • 如何发送截图。我的评论被stackoverflow删除了
  • @Franky 编辑你的问题并上传你的截图。或在其他第三方服务器上传图片并分享图片链接
猜你喜欢
  • 2017-09-16
  • 2019-04-18
  • 2018-05-15
  • 1970-01-01
  • 1970-01-01
  • 2021-11-15
  • 1970-01-01
  • 1970-01-01
  • 2019-07-04
相关资源
最近更新 更多