在电子邮件通知中显示自定义订单元数据值 [英] Display custom order meta data value in email notifications

查看:26
本文介绍了在电子邮件通知中显示自定义订单元数据值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Woocommerce 我使用 "在管理订单中显示 Woocommerce 自定义结账字段值,使其可编辑" 在管理订单页面中显示自定义字段值并运行良好的答案代码.

In Woocommerce I am using "Show Woocommerce custom checkout field value in admin order making them editable" answer code that display a custom field value in admin order pages and works nicely.

我的问题:是否可以在电子邮件通知中显示该自定义字段值?

My question: Is it possible to display that Custom field value in email notification?

推荐答案

您可以使用以下内容在电子邮件通知中显示您的自定义字段发票编号":

You can use the following to display your custom field "Invoice Number" on email notifications:

add_action('woocommerce_email_order_details', 'woocommerce_email_order_invoice_number', 4, 4 );
function woocommerce_email_order_invoice_number( $order, $sent_to_admin, $plain_text, $email ) {
    if( $value = get_post_meta( $order->get_id(), '_billing_options', true ) )
        echo '<p><strong>'.__('Invoice Number').':</strong> '.$value.'</p>';
}

代码位于活动子主题(或活动主题)的 function.php 文件中.经测试有效.

Code goes in function.php file of your active child theme (or active theme). tested and works.

这篇关于在电子邮件通知中显示自定义订单元数据值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆