在WooCommerce中我正在使用"显示WooCommerce在管理顺序中的自定义签出字段值,使其可编辑" 答案代码,该代码在管理订单页面和效果很好。
我的问题:是否可以在电子邮件通知中显示自定义字段值?
您可以在电子邮件通知上使用以下内容显示您的自定义字段"发票号码":
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文件中。测试并有效。