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

Edit customer details in Woocommerce email notifications

WooCommerce 在哪里包含来自第三方插件的自定义字段? 我想编辑订单以显示所有字段。

在 admin-new-order.php 中,我只需将 Woocommerce_email_customer_details 挂钩放在 woocommerce_email_order_meta 上方即可。

只有我如何才能将其与我的客户将收到的电子邮件一起存档?

根据 中的数据,这可以通过以下挂钩函数完成,该函数将允许您编辑帐单格式的地址数据:

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;
}

代码进入活动子主题(或活动主题)的 function.php 文件。

已测试并有效。

For shipping customer details, you will use woocommerce_order_formatted_shipping_address filter hook in the same way…