[英]Edit header and footer only for "customer-on-hold-order" email notifications in WooCommerce
我试图编辑我商店电子邮件的页眉和页脚,但我只能在它直接进入所有电子邮件的模板时进行编辑。
我还尝试将email-header.php和email-footer.php复制到我的子主题,但没有任何反应。
由于模板customer-on-holder-order已经列出了代码
/*
* @hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
...
/*
* @hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
我怎样才能找到/编辑这个? 有什么建议吗?
woocommerce_email_header
和woocommerce_email_footer
动作挂钩出现在多个模板文件中是正确的。
但是,要定位特定的电子邮件,您可以使用$email->id
,因为$email
作为参数传递给两个钩子
所以你得到:
// Header
function action_woocommerce_email_header( $email_heading, $email ) {
// Target
if ( $email->id == 'customer_on_hold_order' ) {
echo 'customer on hold order header';
}
}
add_action( 'woocommerce_email_header', 'action_woocommerce_email_header', 10, 2 );
// Footer
function action_woocommerce_email_footer( $email ) {
// Target
if ( $email->id == 'customer_on_hold_order' ) {
echo 'customer on hold order footer';
}
}
add_action( 'woocommerce_email_footer', 'action_woocommerce_email_footer', 10, 1 );
代码位于活动子主题(或活动主题)的functions.php
文件中。 在 Wordpress 5.8.1 和 WooCommerce 5.8.0 中测试和工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.