如何在 Woocommerce 挂钩中查找字符串 'woocommerce_email_order_details'

How to find a string in Woocommerce hook 'woocommerce_email_order_details'

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

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

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

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

如果你确定它是正确的钩子,你改变的方式是在你的子主题中找到 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