Загрузка...

Disable New Order Email Notifications in WooCommerce for On Hold Status

Learn how to disable `New Order` email notifications in WooCommerce when an order is `On Hold`, and enable it only for orders marked as `Processing`.
---
This video is based on the question https://stackoverflow.com/q/66071746/ asked by the user 'Felipe SooUl' ( https://stackoverflow.com/u/7047810/ ) and on the answer https://stackoverflow.com/a/66072270/ provided by the user 'LoicTheAztec' ( https://stackoverflow.com/u/3730754/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Disable WooCommerce New order email notification if order status is On hold

Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/licensing
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license.

If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
Disabling WooCommerce New Order Email Notifications for On Hold Status

If you're running an online store using WooCommerce, you're probably familiar with the New Order email notification system. By default, WooCommerce sends an email notification to the admin whenever a new order is placed. However, this can sometimes lead to an overwhelming amount of notification emails, especially if some orders end up in the On Hold status. In this guide, we will explore how you can disable the New Order email notification specifically for orders that are put on hold. Additionally, we'll discuss how to modify the notification system to send emails only when an order is marked as Processing.

Understanding the Issue

When an order is placed in your WooCommerce store, the system automatically triggers an email notification to inform the admin right away. This process works smoothly in most cases, but what happens when an order is On Hold? In such scenarios, you might find it unnecessary to be notified via email, particularly if the order requires further action before processing. Here's how to tackle this issue effectively:

The Solution

To achieve the customization of WooCommerce's email notification system, we will utilize a small piece of code that modifies the recipient of the emails based on the order status. The following sections will provide you with clear steps and code snippets to implement this solution.

Step 1: Disabling Emails for On Hold Orders

To stop the New Order email notification from being sent when an order status is On Hold, you need to add the following code to your functions.php file in your active theme or child theme:

[[See Video to Reveal this Text or Code Snippet]]

Explanation of the Code:

The add_filter function hooks into the woocommerce_email_recipient_new_order filter, allowing you to modify the recipient of the New Order email.

The function checks if the order is valid and if its status is On Hold. If it is, the function returns an empty string for the recipient, effectively disabling the email notification.

If the order status is anything other than On Hold, the original recipient email address will be retained.

Step 2: Enabling Emails Only for Processing Orders

If you want to receive the New Order notification only when the status of the order is Processing, you can replace the line in the previous code with the following:

[[See Video to Reveal this Text or Code Snippet]]

Adjusted Code Snippet:

Here’s how the complete function would look:

[[See Video to Reveal this Text or Code Snippet]]

Important Notes

Make sure to test the code after adding it to ensure that it behaves as expected.

It’s crucial to work within a child theme or a backup of your active theme to avoid losing your changes upon theme updates.

Conclusion

By using the above code snippets, you can effectively manage the New Order email notifications sent out by WooCommerce based on the order status. Disabling notifications for On Hold orders helps reduce email clutter, while enabling notifications for only Processing orders keeps you informed on actionable requests. This customization enhances your workflow and can contribute positively to the management of your online store.

Feel free to reach out with questions or share your experiences regarding WooCommerce email management in the comments below!

Видео Disable New Order Email Notifications in WooCommerce for On Hold Status канала vlogize
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять