首页 文章

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

提问于
浏览
1

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

在admin-new-order.php中,我可以通过将 Woocommerce_email_customer_details 挂钩放在 woocommerce_email_order_meta 上方来实现 .

只有我如何通过我的客户将收到的电子邮件存档?

1 回答

  • 0

    根据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过滤器挂钩...

相关问题