【发布时间】:2017-11-07 20:41:01
【问题描述】:
我使用 WC 字段工厂生成了一些自定义字段,包括一个名为“message_to_recipient”的文本框。我想将此传递给发出的电子邮件。
在我的functions.php中,我使用的是这个:
add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
function add_order_email_instructions( $order, $sent_to_admin ) {
$custom_message = get_post_meta( $order->ID, "message_to_recipient", true );
if ( ! $sent_to_admin ) {
echo '<h2>You received a gift Card from '.$order->billing_first_name .' '.$order->billing_last_name.'</h2>';
echo '<p><strong>Message:</strong> ' . $custom_message. '</p>';
}
第一个回声,调用$order->billing_first_name 等工作正常。但第二个没有。
使用过 WC Field Factory,我只是没有使用正确的名称,还是这是从订单中获取元数据的错误钩子?
【问题讨论】:
标签: php wordpress woocommerce orders email-notifications