【问题标题】:How to find a string in Woocommerce hook 'woocommerce_email_order_details'如何在 Woocommerce 钩子“woocommerce_email_order_details”中查找字符串
【发布时间】:2021-09-26 21:39:32
【问题描述】:

我正在尝试在交易电子邮件中查找(并修改)自定义字符串,就像使用 /woocommerce/templates/emails/customer-processing-order.php 制作的字符串一样

在那封电子邮件中,我们在称呼(您好,姓氏) 和电子邮件文本的第一行下有一个自定义文本。

我们确信自定义文本来自 'woocommerce_email_order_details' 钩子

如何编辑和修改那个钩子?

【问题讨论】:

  • 如果您确定挂钩,请通过代码编辑器程序根据挂钩搜索您的主题文件。然后,您可以调整找到的结果或将其添加到您的问题中。能够覆盖现有文本很重要,因为它是一个动作钩子而不是一个 fitler 钩子。添加动作钩子会将新内容添加到现有内容,而不是覆盖现有内容

标签: woocommerce hook-woocommerce


【解决方案1】:

如果您确定它是正确的钩子,您更改的方式是在您的子主题中找到functions.php 文件(您是否使用child theme?),并将以下代码添加到底部. 可以在 modifyEmailText 函数体中修改参数。

add_action( 'woocommerce_email_order_details', 'modifyEmailText', 10, 4 );  

function modifyEmailText($order, $sent_to_admin, $plain_text, $email){
    // modify $plain_text if needed...
}

可能有更好的方法来做到这一点。 Here is a guide to customizing WC order emails.

如果你觉得我的回答对你有帮助,你可以accept my answer

【讨论】:

    猜你喜欢
    • 2019-10-01
    • 2021-04-21
    • 2020-06-11
    • 1970-01-01
    • 2020-05-12
    • 2011-07-13
    • 2021-08-13
    相关资源
    最近更新 更多