简体   繁体   English

在Woocommerce电子邮件通知中编辑客户详细信息

[英]Edit customer details in Woocommerce email notifications

Where does WooCommerce include custom fields from third party plugins? WooCommerce在哪里包含来自第三方插件的自定义字段? I would like to edit the order to display all the fields. 我想编辑显示所有字段的顺序。

In admin-new-order.php, I can just do this by placing the Woocommerce_email_customer_details hook above woocommerce_email_order_meta . 在admin-new-order.php中,我可以通过在Woocommerce_email_customer_details上方放置Woocommerce_email_customer_details钩子来执行此woocommerce_email_order_meta

Only how can I archive this with the email my customer will receive? 只有我才能用我的客户收到的电子邮件将其存档?

Based on the data from this question / answer , this can be done with the following hooked function, that will allow you to edit billing formatted address data: 根据此问题/答案中的数据,可以使用以下挂钩函数来完成此操作,该函数可让您编辑帐单格式的地址数据:

add_filter( 'woocommerce_order_formatted_billing_address', 'custom_email_formatted_billing_address', 10, 2 );
function custom_email_formatted_billing_address( $billing_address, $order ){
    // Get your custom field
    $real_first_name = get_post_meta( $order->get_id(), '_billing_voornaam_1_24', true );

    // Insert the custom field value in the billing first name
    if( ! empty( $real_first_name ) )
        $billing_address['first_name'] .= ' ' . $real_first_name;

    // Hiding Last name
    unset($billing_address['last_name']);

    return $billing_address;
}

Code goes in function.php file of the active child theme (or active theme). 代码进入活动子主题(或活动主题)的function.php文件中。

Tested and works. 经过测试和工作。

For shipping customer details, you will use woocommerce_order_formatted_shipping_address filter hook in the same way… 对于运送客户的详细信息,您将以相同的方式使用woocommerce_order_formatted_shipping_address筛选器挂钩…

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 WooCommerce email 通知中重新订购客户详细信息 - Reorder customer details in WooCommerce email notifications 在客户详细信息之后 WooCommerce 普通电子邮件通知有什么钩子? - What hook for WooCommerce plain email notifications after customer details? 仅为 WooCommerce 中的“客户保留订单”电子邮件通知编辑页眉和页脚 - Edit header and footer only for "customer-on-hold-order" email notifications in WooCommerce 在 Woocommerce 电子邮件通知中显示订单客户备注 - Display order customer note in Woocommerce email notifications 在 Woocommerce 客户电子邮件通知中自定义总计行 - Customizing totals lines in Woocommerce customer email notifications 如何更改电子邮件中的woocommerce客户详细信息标签? - How to change woocommerce customer details labels in email? Woocommerce电子邮件通知中的样式订单详细信息表 - Style orders details table in Woocommerce email notifications 在Woocommerce 3中的客户电子邮件通知上设置跟踪编号链接 - Set a Tracking Number link on customer email notifications in Woocommerce 3 根据 Woocommerce 中的运输方式向客户通知添加回复电子邮件 - Add a reply email to customer notifications based on shipping methods in Woocommerce 在 WooCommerce email 通知中将发件人名称更改为客户账单全名 - Change sender name to customer billing full name in WooCommerce email notifications
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM