您可以使用电子邮件 ID 来定位 WooCommerce 中的特定电子邮件通知。
但是,因为这在您使用的钩子中是未知的,所以我们将通过另一个钩子使电子邮件 ID 全局可用
所以你得到:
// Setting the email_is as a global variable
function action_woocommerce_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ) {
$GLOBALS['email_id_str'] = $email->id;
}
add_action( 'woocommerce_email_before_order_table', 'action_woocommerce_email_before_order_table', 10, 4 );
function filter_woocommerce_email_order_items_args( $args ) {
// Getting the email ID global variable
$refNameGlobalsVar = $GLOBALS;
$email_id = isset( $refNameGlobalsVar['email_id_str'] ) ? $refNameGlobalsVar['email_id_str'] : '';
// Targeting specific email. Multiple statuses can be added, separated by a comma
if ( in_array( $email_id, array( 'customer_completed_order', 'customer_invoice' ) ) ) {
// False
$args['show_purchase_note'] = false;
}
return $args;
}
add_filter( 'woocommerce_email_order_items_args', 'filter_woocommerce_email_order_items_args', 10, 1 );
注意:How to target other WooCommerce order emails
在这个答案中使用:Changing in WooCommerce email notification Order Item table "Product" label