[英]Woocommerce Email Custom field not display in table
I created a site in wordpress using woocommerce and i added custom fields in checkout page, also in email after the checkout.我使用 woocommerce 在 wordpress 中创建了一个站点,并在结帐页面中添加了自定义字段,也在结帐后的电子邮件中添加了自定义字段。
But the problem is custom data (Delivery Method) field is not display under the table in email generated by woocommerce.但问题是自定义数据(交付方法)字段未显示在 woocommerce 生成的电子邮件中的表格下方。
Please help me to solve this issue.请帮我解决这个问题。
Here is my code这是我的代码
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');
function my_woocommerce_email_order_meta_keys($keys)
{
$keys['Delivery Method'] = 'delivery_options';
return $keys;
}
Robin,罗宾,
I have tried your problems one solution hope this will be usefull to you.我已经尝试了您的问题的一种解决方案,希望这对您有用。
Solution I tried (And it worked for me)我试过的解决方案(它对我有用)
/*This is action hook for adding content before the mail template footer*/
add_action( 'woocommerce_email_footer', 'custom_email_footer', 10, 1 );
function custom_email_footer( $email ) {
/*$_POST['billing_delivery_date'] (My custom field variable)*/
if (isset($_POST['billing_delivery_date'])) { /*Get value of the custom field*/
/*Echo the filed value with some string or as you want*/
echo "Delivery date : ".$_POST['billing_delivery_date'];
}
}
There are several woo-commerce hooks available that can be used to add custom data to the email template sent by mail.
有几个 woo-commerce 挂钩可用于将自定义数据添加到通过邮件发送的电子邮件模板。
NOTE: I also used one of them.
注意:我也使用了其中之一。 :-)
:-)
Also The hook you are using will generate or add the custom field into the email template in the order as per the priority.
此外,您使用的钩子将按照优先级的顺序生成自定义字段或将其添加到电子邮件模板中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.