add_action( 'woocommerce_email_order_details', 'get_the_wc_email_id', 9, 4 );
function get_the_wc_email_id( $order, $sent_to_admin, $plain_text, $email ) {
// Will output the email id for the current notification
echo '<pre>'; print_r($email->id); echo '</pre>';
}
代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中 .
获得自定义电子邮件通知的 correct email ID slug 后,您可以在以下任何挂钩上使用它(而不是覆盖电子邮件模板):
1 回答
WooCommerce中不存在
wc_order_email
类或函数,因此我更新了您的问题 .您正在查看的是
$email
变量参数(WC_Email当前类型对象) . 它主要在模板和钩子的各处定义 .要将可用的当前电子邮件ID作为变量,您只需使用
$email_id = $email->id
...要获取自定义电子邮件的当前电子邮件ID,您应该使用此代码(仅适用于 testing ):
代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中 .
获得自定义电子邮件通知的 correct email ID slug 后,您可以在以下任何挂钩上使用它(而不是覆盖电子邮件模板):
•
woocommerce_email_header
(2个参数:$email_heading
,$email
)•
woocommerce_email_order_details
(4个参数:$order
,$sent_to_admin
,$plain_text
,$email
)•
woocommerce_email_order_meta
(4个参数:$order
,$sent_to_admin
,27241227,$email
)•
woocommerce_email_customer_details
(4个参数:$order
,$sent_to_admin
,$plain_text
,$email
)•
woocommerce_email_footer
(1参数:$email
)在这里 example of code 我只针对"New order"电子邮件通知:
代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中 .
经过测试和工作 .