hook woocommerce\\u email\\u order\\u details有4个参数,可以帮助您识别正确的邮件。
add_action( \'woocommerce_email_order_details\', \'so274215_add_transaction_id\', 10, 4);
function so274215_add_transaction_id( $order, $sent_to_admin, $plain_text, $email ){
// decide here wether to show your transaction id
if ( ! $sent_to_admin )
echo \'<span style="color:#555;font-size:1.5em;">Transaction ID: \'.get_post_meta( $order->id, "_transaction_id", true ).\'</span>\';
}
据我所知,最后一个参数$email包含当前消息的名称,以防您想更详细地了解。
if( \'WC_Email_Customer_On_Hold_Order\' == $email ) ...