I found a great code but for some reason, it doesn't work. My PHP version is 7.4.3 The code supposes to disable all emails for products that have the price of $0. Could someone suggest why it wouldn't work? I posted on the thread of bbloomer but he doesn't respond :S
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'bbloomer_disable_customer_order_email_if_free', 10, 2 );
function bbloomer_disable_customer_order_email_if_free( $recipient, $order ) {
$page = $_GET['page'] = isset( $_GET['page'] ) ? $_GET['page'] : '';
if ( 'wc-settings' === $page ) {
return $recipient;
}
if( $order->get_total() == 0 ) $recipient = '';
return $recipient;
}