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



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

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

经过测试并工作。

对于运输客户详细信息,您将以相同的方式使用woocommerce_order_formatted_shipping_address过滤器钩子......

最新更新