Disable Customer Order Email for Free Orders

There are times when you sell free products to give customers access to a membership, an online course, or for other reasons. In this case, you might not want to send them the “Order Completed” email, as the follow-up work is done by your email marketing software or they are automatically redirected to the resource upon checkout.

Of course, you definitely want to keep the “Order Completed” emails for orders that are not $0. Unfortunately, the method suggested by WooCommerce which “unhooks the emails” cannot be used together with a conditional check (in our case we need to verify if the order total is $0), so a workaround is needed. Here’s the fix.

WooCommerce: disable a customer email if the order total is 0

PHP Snippet: Disable Customer Order Email for Free Orders – WooCommerce

// To target another email you can change the filter to e.g.:
// "woocommerce_email_recipient_customer_processing_order"
 
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'phpsof_disable_customer_order_email_if_free', 10, 2 );
 
function phpsof_disable_customer_order_email_if_free( $recipient, $order ) {
    $page = $_GET['page'] = isset( $_GET['page'] ) ? $_GET['page'] : '';
    if ( 'wc-settings' === $page ) {
        return $recipient; 
    }
    if ( (float) $order->get_total() === '0.00' ) $recipient="";
    return $recipient;
}