WooCommerce Low Stock Notification Per Product

Last updated on May 28th, 2018

WooCommerce will send the store administrator an email when a product’s inventory goes below a certain threshold. There are two global inventory thresholds that server for all products. These thresholds are named “Low stock” and Out of stock”. This global setting works great for most stores, but for some it doesn’t work as well as it could. In this how to, we’ll show you how to set up a WooCommerce Low Stock Notification per product.

Let’s say that you have a hardware store, selling all kinds of tools and accessories. When you’ve set up a low stock threshold of 5, it will work great when your drills get low on stock, but if your screws get below 5 stock it is far too low. For screws you’d like to have at least 500 in stock, and thus requires a different low stock notification threshold.

Setting Up a Low Stock Notification

In this post, I’ll share a few code snippets that will help you set up low stock notification for an entire WooCommerce category or an individual product.

Note: If you use one of the code snippets found below know that:

  1. The first code snippet in each group works with WooCommerce 2.5 and WooCommerce 2.6.
  2. The second code snippet in each group works with WooCommerce 3.0
  3. It is probably a good idea to disable the default low stock notifications, otherwise products might trigger the default and custom setup notification.
  4. If you are not sure how to add these code snippets to your site, we described how to add custom snippets in this blog post.

Low stock notification per category

Setting up a low stock notification per category can make sense in a lot of cases such as the example above. Setting up a separate low stock threshold per product may take more effort than needed in some scenarios.

The following code snippet can be used to set up a different low stock notification per category. You can modify your category slugs and threshold in the code. If you want to add more custom thresholds, just add/copy a line in the array and set the category-slug/threshold.

WooCommerce 2.6

WooCommerce 3.0

 

Low Stock Notification Per Product

In other cases it would make sense to have a low stock notification per product. The following code snippet does things the same way as above, allowing you to set a product ID, and a threshold on a per product basis.

WooCommerce 2.6

WooCommerce 3.0

Improving the Low Stock Notification Per Product

The code snippet above works great if you don’t have too many products, but if you have dozens of products it will probably become quite hard to manage in a short amount of time.

In such cases, it is also reasonably easy to improve the custom code you just created. The thing I have in mind is adding a new custom field to the ‘inventory’ product settings panel to set the ‘Low stock threshold’ per product in the user interface.

The following code snippet does all that, including setting the low stock notification based on the custom fields that are added.

WooCommerce 2.6

WooCommerce 3.0

The custom field result should look like:

woocommerce-custom-proudct-low-stock-threshold

Get our best WooCommerce advice!

Delivered directly to your inbox

Your email is 100% private. We hate spam too. Powered by ConvertKit

Keep up-to-date with the weekly newsletter

You will receive a bonus tips, actionable insight, and plugin updates every Wednesday!

100% privacy guaranteed, unsubscribe with one click.