WooCommerce 电子邮件模板自定义

Posted

技术标签:

【中文标题】WooCommerce 电子邮件模板自定义【英文标题】:WooCommerce Email Template Customization 【发布时间】:2020-08-31 18:20:45 【问题描述】:

我正在尝试在 WooCommerce 网站的订单确认电子邮件中添加一段。我在我的子主题的 functions.php 文件中添加了对 WooCommerce 的支持。然后我将一个电子邮件模板复制到我的子主题中的正确文件夹中。这是我尝试的模板文件。但是当我(通过插件)测试电子邮件时,我得到,“您的网站上出现了严重错误。”我通过验证器运行了 PHP,但出现了一个错误 - 但我不熟练使用 PHP。有人可以帮我弄清楚要更改什么才能成功添加段落吗?我在暂存环境中工作。提前致谢。

<?php /* translators: %s: Customer first name */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
<?php /* translators: %s: Order number */ ?>
<p><?php printf( esc_html__( 'Just to let you know — we\'ve received your order #%s, and it is now being processed:', 'woocommerce' ), esc_html( $order->get_order_number() ) ); ?></p>


<p><?php printf( esc_html__( 'We are busy baking your products for delivery from our kitchen to your door\. Any products ordered last week\, including over the past weekend\, are being baked this week and will ship next week\. So\, your order will be delivered in 3 to 10 days from the date of your order\. Look for another email providing your tracking number.'); ?> </p>
<?php

【问题讨论】:

【参考方案1】:

存在语法错误。试试下面更正的那个。

<p><?php printf( esc_html__( 'We are busy baking your products for delivery from our kitchen to your door. Any products ordered last week, including over the past weekend, are being baked this week and will ship next week. So, your order will be delivered in 3 to 10 days from the date of your order. Look for another email providing your tracking number.')); ?> </p>

【讨论】:

以上是关于WooCommerce 电子邮件模板自定义的主要内容,如果未能解决你的问题,请参考以下文章

WooCommerce Sensei 电子邮件自定义

在 Woocommerce 中使用电子邮件 ID 定位特定电子邮件

为 Woocommerce 电子邮件主题启用自定义字段占位符

将附件添加到 WooCommerce 自定义电子邮件

在 WooCommerce 新用户注册电子邮件中添加自定义字段

php WooCommerce自定义电子邮件标题