【问题标题】:Change a text in Woocommerce customer processing and completed email notifications在 Woocommerce 客户处理和完成的电子邮件通知中更改文本
【发布时间】:2019-02-03 18:53:24
【问题描述】:

我正在尝试使用 Woocommerce 挂钩来更改特定的电子邮件模板。我想在我的functions.php 文件中覆盖customer-processing-order.phpcustomer-completed-order.php 中的文本。这是我正在使用的代码:

add_action( 'woocommerce_email_customer_details', 'hitt_processing_customer_email', 10, 4 );
function hitt_processing_customer_email( $order, $sent_to_admin, $plain_text, $email ) {

    if( 'customer_processing_order' == $email->id ){
        echo '<p>My custom content here</p>';
    }

    if( 'customer_completed_order' == $email->id ){
        echo '<p>My custom content here</p>';
    }
}

但这似乎不起作用。我将自己设置为客户,当我收到 “您的订单正在处理中” 电子邮件时,它没有添加自定义文本。我做错了什么?

【问题讨论】:

  • 您不能使用挂钩来更改从电子邮件开始的文本,因为它在相关模板本身中是硬编码的......因此您需要通过您的活动主题覆盖两个相关模板as explained in this official documentation

标签: php wordpress woocommerce orders email-notifications


【解决方案1】:

我意识到上面的代码可以工作,但它把它放在了错误的地方,所以我没有看到变化,所以这里是修改后的代码,将文本放在默认文本下方但在价格表上方:

add_action( 'woocommerce_email_before_order_table', 'custom_content_to_processing_customer_email', 10, 4 );
function custom_content_to_processing_customer_email( $order, $sent_to_admin, $plain_text, $email ) {

if( 'customer_processing_order' == $email->id ){

    echo '<p>Your custom text on the customer processing order</p>';

}
if( 'customer_completed_order' == $email->id ){
    echo '<p>Your custom text on the customer completed order email.</p>';
}

}

【讨论】:

    猜你喜欢
    • 2018-05-31
    • 2017-05-19
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-08
    相关资源
    最近更新 更多