简体   繁体   English

Woocommerce 电子邮件自定义字段未显示在表格中

[英]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'];
 }
}
  • Understanding理解

    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.此外,您使用的钩子将按照优先级的顺序生成自定义字段或将其添加到电子邮件模板中。

  • Screenshot 1截图 1

    Before used hook / while using your hook :使用钩子之前/使用钩子时: 前图像

  • Screenshot 2截图 2

    After Using (woocommerce_email_footer) hook:使用 (woocommerce_email_footer) 钩子后: 后图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 WooCommerce email 通知中为管理员显示自定义字段 - Display a custom field in WooCommerce email notifications for admin 在电子邮件通知上显示 WooCommerce 自定义结帐字段值 - Display a WooCommerce custom checkout field value on email notification 在 Woocommerce 电子邮件通知上显示自定义元字段值 - Display custom meta field value on Woocommerce email notifications 在 WooCommerce 电子邮件订单项目中显示可变产品的产品自定义字段 - Display a product custom field for variable products in WooCommerce email order items 在Woocommerce管理员电子邮件通知中显示产品自定义字段值 - Display a product custom field value in Woocommerce admin email notifications 在Woocommerce电子邮件通知模板中显示自定义字段值 - Display a custom field value in Woocommerce email notification template 在 WooCommerce 中显示谢谢基于自定义表格的自定义字段值 - Display in WooCommerce thankyou a custom field value based on a custom table 在WooCommerce购物车和结帐表中显示产品自定义字段值 - Display a product custom field value in WooCommerce cart and checkout table 对Woocommerce电子邮件主题启用自定义字段占位符 - Enable a custom field placeholder to Woocommerce email subject Woocommerce预订-将自定义字段添加到管理员电子邮件 - Woocommerce Bookings - adding custom field to admin email
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM