Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 电子商务电子邮件自定义字段未显示在表中_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 电子商务电子邮件自定义字段未显示在表中

Php 电子商务电子邮件自定义字段未显示在表中,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我使用woocommerce在wordpress中创建了一个网站,并在结帐页面中添加了自定义字段,结帐后也在电子邮件中添加了自定义字段 但问题是自定义数据(传递方式)字段未显示在woocommerce生成的电子邮件中的表下 请帮我解决这个问题 这是我的代码 add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys'); function my_woocommerce_email_

我使用woocommerce在wordpress中创建了一个网站,并在结帐页面中添加了自定义字段,结帐后也在电子邮件中添加了自定义字段

但问题是自定义数据(传递方式)字段未显示在woocommerce生成的电子邮件中的表下

请帮我解决这个问题

这是我的代码

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;
}

罗宾

我尝试过你的问题,希望这对你有用

我尝试过的解决方案(它对我有效)

  • 理解 有几个woo commerce挂钩可用于向通过邮件发送的电子邮件模板添加自定义数据

    注意:我还使用了其中一个。:-)

另外,您正在使用的钩子将按照优先级的顺序生成自定义字段或将其添加到电子邮件模板中

  • 屏幕截图1

    使用挂钩前/使用挂钩时:

  • 屏幕截图2

    使用(woocommerce\u email\u footer)钩子后:

/*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'];
 }
}