【发布时间】:2017-04-13 13:21:53
【问题描述】:
我有一个 Woocommerce 产品的自定义字段,我想在订单电子邮件中显示它的价值。
由于我使用的是自定义产品提交表单,因此我在下面的自定义字段中添加了此代码以创建自定义字段:
<?php
WCVendors_Pro_Form_Helper::select( array(
'post_id' => $object_id,
'class' => 'select2',
'id' => 'wcv_custom_product_ingredients',
'label' => __( 'What time?', 'wcvendors-pro' ),
'placeholder' => __( 'Pick a time', 'wcvendors-pro' ),
'wrapper_start' => '<div class="all-100">',
'wrapper_end' => '</div>',
'desc_tip' => 'true',
'description' => __( 'Pick a time', 'wcvendors-pro' ),
'options' => array( '12:00 midnight' => __('12:00 midnight', 'wcv_custom_product_ingredients'), '12:15 midnight'=> __('12:15 midnight', 'wcv_custom_product_ingredients') )
) );
?>
我也尝试将下面的代码添加到functions.php,但这只会显示“什么时间?”没有价值的订单电子邮件...
add_action('woocommerce_email_after_order_table', 'wcv_ingredients_email');
function wcv_ingredients_email() {
$output = get_post_meta( get_the_ID(), 'wcv_custom_product_ingredients', true );
echo 'What time? ' . $output . '<br>';
}
可能是什么问题?
【问题讨论】:
标签: php wordpress woocommerce orders email-notifications