How to Hide Customer Order Email For Free Orders WooCommerce

WooCommerce Hide Customer Order Email For Free OrdersThe order emails in WooCommerce are rather bland or too generic from the users’ point of view. WooCommerce includes several order statuses that may not match your store’s flows, but you can still mark orders with custom status such as Payment Pending, Processing, On Hold, Failed, etc.

WooCommerce Hide Customer Order Email For Free Orders

While making impressive HTML emails is truly an achievement in itself, WooCommerce offers several options so that even WordPress beginners can create emails.

WooCommerce Customer Emails

“Vanilla” offers WooCommerce email notifications sent to customers in response to their interactions with the store. Here are the most important emails for the customers of your WooCommerce store:

  • New Order
  • Canceled Order
  • Failed Order
  • Order On hold
  • Processing Order
  • Completed Order
  • Refunded Order
  • Customer Invoice
  • Customer Note
  • Reset Password
  • New Account

However, you can add customized emails as well. To check email notifications, go to WooCommerce > Settings and click on the Emails tab:WooCommerce Order Emails

WooCommerce Hide Customer Order Emails for Free Orders

There are times when you sell free products to give customers access to registered members. This means you might not want to send them the “Order Completed” email, as your email marketing software does the follow-up work, or they are automatically redirected to the resource upon checkout.

You will want to keep the “Order Completed” emails for orders that are not $0. However, WooCommerce does not have this built-in functionality. We will use a custom PHP code snippet to achieve this.

Steps to Hide Customer Order Emails for Free Orders

Here are the steps that you need to follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to hide customer order emails for free orders.
  3. Click anywhere on the text editor and scroll to the bottom of the functions.php file. Paste the code at the end:
/**

 * @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', 'njengah_disable_customer_order_email_if_free', 10, 2 );




function njengah_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;

}
  1. Click on the Save changes button at the bottom of the text editor screen.
  2. You have successfully added the code snippet required to hide customer order emails for free orders.

Conclusion

In summary, this post shares how to hide customer order email for free orders. Moreover, I have highlighted some of the Email notifications supported by WooCommerce. However, you can add customized emails. If you are not familiar with code, please consider hiring a WordPress developer so that you do not break down your site.

Similar Articles

  1. How to Hide Prices From Google In WooCommerce