WooCommerce: 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 cases, 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

/**
 * @snippet       Disable Customer Order Email for Free Orders - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    Woo 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
// 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', '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 ( (float) $order->get_total() === '0.00' ) $recipient = '';
    return $recipient;
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

21 thoughts on “WooCommerce: Disable Customer Order Email for Free Orders

  1. Thx for the code – but unfortunately, in latest WooCommerce 3.8, woocommerce_email_recipient_customer_processing_order & woocommerce_email_recipient_customer_completed_order hooks are not available anymore.
    Any alternative?

    1. Actually, your code still works. Only had to change the following line. Probably more related to how PHP 7.2 handles float.

      if( $order->get_total() == 0 ) $recipient = '';

      (and found where to look at for the hooks you have used, they still exist – as composite: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Email.html#351)

      1. Excellent, thank you!

  2. Thanks for this code! Do you maybe know how to use a woocommerce custom field email adres as recipient in stead of $recipient = ‘ ‘?
    Thanks in advance!

    1. Hello Mos, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. Thank you so much for this snippet, unfortunately it does not work for us.
    We have wordpress 5.1 + Kadeence woocommerce email designer plugin.

    1. Hey Jakub! Does it work if you deactivate email designer?

  4. Thank you for the code <3

    1. You’re welcome Michelle ๐Ÿ™‚

  5. Rodolfo,
    You are a savior. That works so well. But I have another question-

    I want to disable all customer emails in woocommerce (because I want them to be taken care by external application e.g. MailChimp since they offer more control on content customization). However, I want to receive notification on new orders etc. Just wan to disable all customer emails.
    Do you know if there is any easy fix, or a plugin that may do so?

    Thank you so much in advance.

    1. Hello Nick – thanks so much for your comment! Can you not disable them one by one from the WooCommerce > Emails settings?

  6. Hi Rodolfo,
    Is it possible to make the sending of the “customer_new_account” email conditional based on product on order?

    So if product id “123” is part of the order, don’t send the new-account email?

    1. Hi Jason – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  7. I have a question about a somewhat related topic. Because I couldn’t find anything more related on your site I decided to post my question here. Hope that’s OK?

    WooCommerce order numbers are not sequential. I know there is a SkyVerge plugin that takes care of that, but could you provide us with a snippet to fix this?

    1. Hey Steven, that plugin is probably faster than trying to code it ๐Ÿ™‚ Sorry!

  8. Thanks Rodolfo. It works like a charm.
    Is there any simple solution to display just a single line of text instead of the entire WooCommerce table? I have only one (free) product and don’t want to show the default complex Woo table (with Product, Quantity, Price, VAT and such).

    1. Nick, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  9. What about showing the price as FREE instead of “0”? I have downloadable products so I still need the email to go out but it would be great if it can show FREE instead of “0”.

  10. Thank you, this is just what I was looking for. I can disable a couple of plugins now and improve the full load page perfomance ๐Ÿ˜‰

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *