[英]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.