WooCommerce: disable "completed" email to customer on specific orders

If you need to avoid sending "completed order" emails to customers on specific orders, you can use this function which checks if a metafield is "true. If it is "true" then it will not send the "completed email" to the customer on the specific order.


add_filter( 'woocommerce_email_recipient_customer_completed_order', 'cco_disable_customer_order_email_if_free', 10, 2 );
function cco_disable_customer_order_email_if_free( $recipient, $order ) {
	$page = $_GET['page'] = isset( $_GET['page'] ) ? $_GET['page'] : '';
	if ( 'wc-settings' === $page ) { return $recipient;}
	return ( ( 1 == get_post_meta( $order->get_id(), '_not_send_completed_order_mail', true ) )) ? $recipient = '' : $recipient;
}

// If you want to target a different email, you can change the filter to e.g: "woocommerce_email_recipient_customer_processing_order"

How do I set a customfield that I can check?
You can use ACF (advanced Custom Fields) to create a custom field in WordPress CMS that you can check on the order. A true/false field with the metafield mentioned that the function should check against.