@pinelab/vendure-plugin-stock-monitoring
v3.1.0
Published
Vendure plugin for monitoring stock levels per variant. View low stock in your dashboard or get notified through an event.
Downloads
753
Readme
Vendure stock monitoring plugin
This plugin helps you monitor the stock levels in two ways:
- A dashboard widget that displays variants that have stock level's below their threshold
- An event is emitted when a variant's stock level drops below a given threshold after each placed order.
Getting started
- Add the plugin to your
vendure-config.tsto expose aproductVariantsWithLowStockquery 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
- This plugin doesn't use the
StockLocationStrategybecause of performance reasons. Instead, it fetches the stock level for each variant from the database and calculates its absolute stock based on thestockOnHandandstockAllocatedfields. - Performance: Each allocation, sale or adjustment in
StockMovementEventwill create a job that triggers a stock check: get saleable stock, compare with variant threshold, and emit event if variant dropped below threshold.
