WooCommerce - 使用"New Order"电子邮件发送客户消息



我们使用Woocommerce来销售汽车零部件。通常,客户在订单过程中将(重要(消息写入文本字段。我们从系统收到"新订单"电子邮件,但不包括该消息。我们如何更改电子邮件模板才能接收来自客户的消息?

谢谢你的帮助

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

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

wp-content/plugins/woocommerce/templates/emails

重要提示:请勿编辑插件目录中的文件,因为这样您的更改将在第一次插件更新时丢失。可以通过将此模板复制到

yourtheme/woocommerce/emails/template_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>';
}

相关内容

最新更新