There are times when you sell free products to give customers access to a membership, an online course, or for other reasons. In these cases, you might not want to send the “Order Completed” email or get the “New Order” transactional notification, so that you can avoid sending and receiving hundreds of emails.
Of course, you’d still want to keep the order emails for amounts above $0. Here’s the fix.
PHP Snippet: Disable WooCommerce Order Emails If Total = 0
/**
* @snippet Disable Emails for Free Orders - WooCommerce
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
// To target additional emails you can add EMAIL_ID to this filter:
// "woocommerce_email_recipient_EMAIL_ID"
// Find EMAIL_ID: businessbloomer.com/woocommerce-add-extra-content-order-email
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'bbloomer_disable_order_email_if_free', 9999, 2 );
add_filter( 'woocommerce_email_recipient_new_order', 'bbloomer_disable_order_email_if_free', 9999, 2 );
function bbloomer_disable_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;
}
Hi, This is not working for custom status. eg: add_filter( ‘woocommerce_email_recipient_customer_assembly_order’, ‘hoodsly_email_recipient_customization’, 10, 2 );
How can I solve this?
Hi Richard 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!
Hi Rudolfo
Just tried the snippet with WooCommerce 5.5.2 and PHP 7.4.22 – unfortunately it isn’t working.
Update: removed (float) as Sophie suggested, and it works:
Nice!
My web dev inserted your code for me but it is no longer working. 🙁 I read through the comments but don’t see the differences (even using a diff tool).
I’m inserting the PHP code using My Custom Functions and when I “turn on” the code I get this:
Sorry, but your code causes a “Fatal error”, so it is not applied!
Please, check the code and try again.
It used to work but I can’t figure out what to change now. Please advise. I hate customers getting tons of emails for orders that are “0”. It makes no sense to me!
What’s the Fatal Error description? That should help you and me finding out what’s going on
Hi Rodolfo,
I works with woo subscriptions emails as well (once you find the correct hook )
I had to modify your code with another users tip (removing the float)
Nice!
Hi,
I added the code to functions.php. But still, the order completed mail is going to the customer. My woocommerce Version 4.6.0. Can you please let me know the modified code if any.
Thanks
Hi Hasan, works for me, sorry. Do you use decimals in your prices (0.00)?
Hi Rodolfo,
thank you very much for this tip, in my case I would like to disable ADMIN email for new free order, is the following snippet correct please?
Thanks!
Ludovic (from Reunion island)
Hey Ludovic, no you need to change this hook only: woocommerce_email_recipient_customer_completed_order
Thank you for your reply, for new order email to the admin, this hook is the good one please?
woocommerce_order_status_pending_to_completed_notification
No, the filter would be ‘woocommerce_email_recipient_admin_new_order’ (untested)
Thanks for this great code, Rodolfo!
I had to adapt the code as AlbanS suggested – our page runs on php 7.4.8
Nice!
Thank you for this incredible code!
I want to also disable the email for a particular product. How can I achieve that?
TIA
Hi Vincent, 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!
Hello,
Thank you very much for your article.
Can this work to deactivate notification emails for a new order?
I do not wish to receive emails for free orders.
I have try (WC 3.8.1) :
But doesn’t work :/
Thx for you work
Weird. Does it work for customer emails?
Ho Rodolpho ! Just to be sure, this snippet ONLY blocks Customer email for free products, but it does NOT block email sent to admin when a customer orders a free product right ?
This 2nd option would maybe be useful to avoid receiving hundreds of emails everytime a user ‘buy’ a free product…
Is that something possible for which I should get a quote please ? 🙂
Thanks !
Exactly, Ben! If you’d like to get a quote, feel free to contact me here. Thanks a lot
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?
Actually, your code still works. Only had to change the following line. Probably more related to how PHP 7.2 handles float.
(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)
Excellent, thank you!
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!
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!
Thank you so much for this snippet, unfortunately it does not work for us.
We have wordpress 5.1 + Kadeence woocommerce email designer plugin.
Hey Jakub! Does it work if you deactivate email designer?
Thank you for the code <3
You’re welcome Michelle 🙂
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.
Hello Nick – thanks so much for your comment! Can you not disable them one by one from the WooCommerce > Emails settings?
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?
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
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?
Hey Steven, that plugin is probably faster than trying to code it 🙂 Sorry!
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).
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
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”.
Hello Dror, would this help > https://businessbloomer.com/woocommerce-display-free-instead-0-00-empty-price/ ?
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 😉
Great 🙂