我試圖編輯我商店電子郵件的頁眉和頁腳,但我只能在它直接進入所有電子郵件的模板時進行編輯。
我還嘗試將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 );
我怎樣才能找到/編輯這個?有什么建議嗎?
uj5u.com熱心網友回復:
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 中測驗和作業
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/336503.html
標籤:php WordPress的 求购 电子邮件通知
