Commercio Docs

Inventory Management

Manage stock levels and track inventory transactions.

Set Stock

Set initial stock level for a product in a warehouse

import { StockService } from "commercio";

// Set stock
await stockService.setStock(product.id, warehouse.id, 100);

// Get stock
const stock = await stockService.getStock(product.id, warehouse.id);
console.log(`Current stock: ${stock?.quantity}`);

Stock Reservation Flow

How stock reservations prevent overselling

Reservation Process

100%
Loading diagram...

Inventory Transaction Flow

How inventory transactions update stock levels

Transaction Flow

100%
Loading diagram...

Stock Operations

Adjust Stock

Increase or decrease stock levels

// Increase stock
await stockService.adjustStock(product.id, warehouse.id, 50);

// Decrease stock
await stockService.adjustStock(product.id, warehouse.id, -25);

// Get total stock across all warehouses
const totalStock = await stockService.getTotalStock(product.id);