# 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:
- 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';
import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
plugins: [
StockMonitoringPlugin.init({
globalThreshold: 10,
uiTab: 'My Admin UI Tab',
}),
// Add the widget to the admin ui
AdminUiPlugin.init({
port: 3002,
route: 'admin',
app: compileUiExtensions({
outputPath: path.join(__dirname, '__admin-ui'),
extensions: [StockMonitoringPlugin.ui],
}),
}),
];
For more configuration options regarding the admin ui, check the docs.
When you start the server and login, you can find stock-levels under the add widgets 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. - Stock notifications are only emitted after an order is placed. Manual stock changes via the admin UI will not trigger a notification.
Need help? Get In Touch