【问题标题】:Edit customer details in Woocommerce email notifications在 Woocommerce 电子邮件通知中编辑客户详细信息
【发布时间】:2018-01-31 15:30:20
【问题描述】:

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

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

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

【问题讨论】:

    标签: php wordpress woocommerce orders email-notifications


    【解决方案1】:

    根据来自this question / answer 的数据,这可以通过以下钩子函数来完成,这将允许您编辑帐单格式的地址数据:

    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 文件中。

    经过测试并且有效。

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

    【讨论】:

    • 太棒了。几乎在那里,因为它仍然显示两个字段。显示 billing_first_name 很好,但 billing_last_name 不应该是可见的。
    • @Carina092 更新了你可以试试……
    • 不应该包含一些东西吗?试了一下,给了一个白页。
    • @Carina092 抱歉……又更新了……没有白页了。
    猜你喜欢
    • 2021-04-25
    • 2023-01-16
    • 2018-07-27
    • 2018-08-15
    • 1970-01-01
    • 2023-03-25
    • 2023-02-21
    • 2021-10-27
    • 2018-06-05
    相关资源
    最近更新 更多