Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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
Wordpress Woocommerce-使用“发送客户信息”;“新订单”;电子邮件_Wordpress_Woocommerce - Fatal编程技术网

Wordpress Woocommerce-使用“发送客户信息”;“新订单”;电子邮件

Wordpress Woocommerce-使用“发送客户信息”;“新订单”;电子邮件,wordpress,woocommerce,Wordpress,Woocommerce,我们利用Woocommerce销售汽车零件。 在订购过程中,客户通常会在文本字段中写入一条(重要)消息。 我们从系统中收到“新订单”电子邮件,但该消息未包含在内。 我们如何更改电子邮件模板以接收客户的邮件 感谢您的帮助您可以在Wp Admin部分的WooCommerce设置区域中配置确认电子邮件的一些详细信息:WooCommerce->settings->Emails 您还可以在此处编辑模板文件: wp-content/plugins/woocommerce/templates/emails

我们利用Woocommerce销售汽车零件。 在订购过程中,客户通常会在文本字段中写入一条(重要)消息。 我们从系统中收到“新订单”电子邮件,但该消息未包含在内。 我们如何更改电子邮件模板以接收客户的邮件


感谢您的帮助

您可以在Wp Admin部分的WooCommerce设置区域中配置确认电子邮件的一些详细信息:WooCommerce->settings->Emails

您还可以在此处编辑模板文件:

wp-content/plugins/woocommerce/templates/emails
重要信息:不要编辑插件目录中的文件,因为这样一来,您的更改将随着第一次插件更新而丢失。通过将此模板复制到,可以覆盖此模板

yourtheme/woocommerce/emails/template\u name.php


因此,您可以编辑模板文件并将文本字段数据附加到电子邮件中。

以备将来其他人需要答案时使用。如果您希望将客户备注添加到新订单电子邮件中,您可以使用其中一个操作挂钩,而不是覆盖电子邮件模板:

// Hook this function into woocommerce_email_order_meta 
add_action( 'woocommerce_email_order_meta', 'woo_add_customer_note_to_email', 10, 3 );

function woo_add_customer_note_to_email( $order, $is_admin, $plain_text = false ) {
    // Retrieve the customer note as a variable from the $order array.
    $customer_note = $order->get_customer_note();

    // You want to send those only to the Admin, or only customers, modify here. Right now it's only sending to admin emails.
    if ( !$is_admin || $is_admin && empty($customer_note) ) {
       return;
    }
    // Setup our html markup for inclusion in the email. Note, you should inline your styles, which is best practice for HTML emails.
    echo '<div style="font-family: &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; margin-top: 40px;"><h2 style=""color: #6a6057; display: block; font-family: &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-size: 18px; font-weight: bold; line-height: 130%; margin: 0 0 18px; text-align: left;">Customer Notes</h2>';

    echo '<blockquote><span style="color: #505050; font-family: &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif;">' . wpautop( wptexturize( $customer_note ) ) . '</span></blockquote>';

    echo '</div>';
}
//将此函数挂接到woocommerce\u email\u order\u meta
添加操作('woocommerce\u email\u order\u meta'、'woo\u add\u customer\u note\u to\u email',10,3);
函数woo\u将客户注释添加到电子邮件($order,$is\u admin,$plain\u text=false){
//从$order数组中检索作为变量的客户注释。
$customer\u note=$order->get\u customer\u note();
//你想只发送给管理员,或者只发送给客户,在这里修改。现在它只发送给管理员电子邮件。
如果(!$is_admin | |$is_admin&&empty($customer_note)){
返回;
}
//设置要包含在电子邮件中的html标记。注意,您应该内联样式,这是html电子邮件的最佳实践。

echo“这正是我不知道该怎么做的部分,也是我为什么在这里问这个问题。在管理中,没有办法将order_comments字段添加到电子邮件中。在模板中,我不知道如何实现该字段。根据经验,在管理领域没有办法做到这一点。我在18个月左右之前就这样做了,并且工作得很好。这是非常重要的。”我只是问一些基本的HTML和PHP.Sam,有人能给我举个脚本/代码的例子吗?