How to Disable Order Email for Free Orders in WooCommerce?

Whenever an order is completed, you send an order completed email. However, you do not require such emails every time. When you are offering free products to upsell further, you do not need an order email. In such scenarios, your email marketing software does the follow up work. Or else, your customer is automatically redirected on the resource page. So, further, you will learn how to disable order email for free orders. 

You do not need such emails whenever you are selling free products. One might upsell a membership or online course via such offerings. However, you will not always sell $0 priced products. Henceforth, you need a specific order email for your every paid order. 

Unfortunately, You cannot use WooCommerce ‘Unhook the emails’ method simultaneously. So, you need to work around to fix this problem. Let’s see how you can do it. 

PHP Snippet: Disable Customer Order Email for Free Orders or $0 Orders in 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;
}

Where do you add this snippet?

So, this is how you activate this snippet in WooCommerce. It is a great way to encourage upselling via free or $0 priced products. Also, it is easier to activate this function with this code. So, to apply this code, just add this PHP snippet at your child theme function.php file’s bottom. It should be placed before “?>”, if you have it there. Apart from this, CSS goes in your child theme style.css file. 

Is this snippet still valid?

So, this is how you disable order email for free orders. So, I have applied this code on the Storefront theme and WordPress friendly hosting PHP 7.3. Let me know if everything works as expected. Share it further if you find this snippet useful for you and it had saved your time.

Also Read, How to Add Content to Order Email in WooCommerce?

How to Set Custom WooCommerce Order Status for New Orders?

Important links: WooCommerce – https://woocommerce.com/