Pinelab Plugins Pinelab
# Install this plugin
npm install @pinelab/vendure-plugin-stock-monitoring

Vendure stock monitoring plugin

This plugin helps you monitor the stock levels in two ways:

  1. A dashboard widget that displays variants that have stock level's below their threshold
  2. An event is emitted when a variant's stock level drops below a given threshold after each placed order.

Getting started

  1. Add the plugin to your vendure-config.ts to expose a productVariantsWithLowStock query in the admin API.
import { StockMonitoringPlugin } from '@pinelab/vendure-plugin-stock-monitoring';

plugins: [
  StockMonitoringPlugin.init({
    globalThreshold: 10,
    uiTab: 'My Admin UI Tab',
  }),
];

The "Low stock" widget is provided as a React Dashboard extension — no Admin UI compilation step is needed.

When you start the server and login, you can find Low stock under the dashboard's add widget button.

Caveats

  1. This plugin doesn't use the StockLocationStrategy because of performance reasons. Instead, it fetches the stock level for each variant from the database and calculates its absolute stock based on the stockOnHand and stockAllocated fields.
  2. Performance: Each allocation, sale or adjustment in StockMovementEvent will create a job that triggers a stock check: get saleable stock, compare with variant threshold, and emit event if variant dropped below threshold.

Security

We try to keep plugins small and focussed, with minimal external dependencies: preferably none. Most of our plugins are using NPM Trusted Publishing with OIDC, and the ones that aren't are in the process of being migrated.

Need help? Get In Touch