我正在研究由其他一些德国开发人员为 woocommerce 创建的主题。我已经创建了我的子主题并使用子主题的 functions.php 来更改网站的功能。
当客户订购产品时,他会收到一封电子邮件,其中包含订单表、客户信息和账单地址以及客户发货。我想删除表格下方的所有内容并添加我自己的文本(客户信息 + 账单、送货和取货地址)。
我在发送给客户的电子邮件中的订单表正下方添加了我自己的文本,但是我无法删除默认显示在我的自定义添加文本下方的信息。我发现负责获取和显示数据的钩子是woocommerce_email_order_meta
,但我不知道如何删除它或阻止它执行。我不想在模板文件中进行更改,我想全部通过钩子来完成。
到目前为止,我已经尝试这样做:
remove_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
我点击了链接:Delete order info section from email template in woocommerce并尝试了以下代码,但没有奏效。
function so_39251827_remove_order_details( $order, $sent_to_admin, $plain_text, $email ){
$mailer = WC()->mailer(); // get the instance of the WC_Emails class
remove_action( 'woocommerce_email_order_details', array( $mailer, 'order_details' ), 10, 4 );
}
add_action( 'woocommerce_email_order_details', 'so_39251827_remove_order_details', 5, 4 );
我怎样才能做到这一点?