Automating and refining WooCommerce low stock email notifications for a grocery retailer

Overview

A grocery retailer using WooCommerce reported that low stock notification emails were no longer being sent after a custom inventory import update. The problem began immediately after the new import process went live in late June, disrupting the automated low stock alerts the client relied on for daily restocking.

Freshy’s development team identified that the custom inventory import bypassed WooCommerce’s default stock update hooks, preventing the low stock emails from triggering. The solution involved creating a custom notification system to restore alerts and adding a safeguard to prevent import updates from overwriting manually managed stock settings.

Issue background

The client’s WooCommerce store contained hundreds of perishable products managed through automated inventory imports from a point-of-sale system. Before the new import workflow was introduced, WooCommerce handled inventory updates natively, triggering the woocommerce_low_stock_product action when product stock dropped below the defined threshold.

After the update, low stock alerts stopped completely. The client confirmed that:

  • Email delivery was not the issue (other WooCommerce emails were sending correctly).
  • Thresholds and recipient addresses were configured properly.
  • The “Low stock notification” option disappeared from the WooCommerce > Emails list.

Diagnosis

Freshy’s development team reviewed the new inventory import process and discovered that the import scripts were directly updating stock quantities in the database rather than using WooCommerce’s internal stock management functions such as:

wc_update_product_stock();
do_action('woocommerce_low_stock_product', $product);

Because these hooks were skipped, WooCommerce never recognized that a product had reached a low stock threshold, and therefore no notification emails were sent.

The investigation also uncovered that:

  • The import process was overwriting the “Manage stock” setting on certain products.
  • Items marked manually as “Out of stock” reverted to “In stock” after import.
  • The site’s existing “low stock” report excluded draft products.

Resolution steps

  1. Restore low stock email functionality – Developed a custom PHP function to replicate WooCommerce’s native notification behavior. The new script evaluated inventory levels after every import run and triggered email notifications for any product below the low stock threshold.
wc_trigger_stock_change_notifications( $product );
  1. Create a custom import-triggered email system – Added a daily batch email summarizing all products that reached low stock levels during import. The new system was independent from WooCommerce’s default notification class and fully customizable in design and recipient list.
  2. Prevent overwriting manually managed stock – Updated the import script to skip products with “Manage stock” unchecked. Ensured the system ignored manual overrides so users could mark products as “Out of stock” without having them reverted by the import.
  3. Fix missing products in the low stock report – Updated the query used to generate the report to include draft products:
'post_status' => array('publish', 'draft'),
  1. Address global threshold discrepancies – Verified that WooCommerce was using a global threshold (set to 2). Explained that exports showing different thresholds were likely pulling from residual custom fields left over from testing.
  2. Improve accuracy and reduce false positives – Adjusted logic to ensure simple and variable products were handled correctly. Tested against both parent and variation products. Resolved discrepancies between export data and live stock levels.
  3. Provide client workflow flexibility – Disabled the custom low stock batch email when requested. Recommended transitioning to an automated daily product export instead, providing inventory and threshold data in CSV format. Outlined a Zapier-based solution for automatic email delivery of the export using WP All Export Pro.

Final outcome

The WooCommerce low stock notification system was successfully restored and improved. The store now:

  • Sends real-time notifications for individual low-stock events.
  • Automatically summarizes import-related low-stock items when needed.
  • Prevents imports from overwriting manual stock settings.
  • Provides a path for future automation through scheduled CSV exports.

The client’s daily operations were stabilized, and product stock management was restored without disrupting the ongoing import process.

Key takeaways

  • Direct database updates in WooCommerce can bypass essential stock-related hooks.
  • When customizing inventory imports, always trigger the woocommerce_low_stock_product or use wc_update_product_stock().
  • Avoid overwriting manually managed stock — use “Manage stock” logic as a safeguard.
  • Automated exports via WP All Export Pro and Zapier provide scalable inventory reporting.
  • Combining custom notification systems with native WooCommerce functions ensures long-term stability and flexibility.

If your WooCommerce store’s stock alerts or imports have stopped working correctly, Freshy can help you rebuild a reliable system that integrates seamlessly with your workflows.
Contact Freshy for expert WooCommerce customization and automation support.