Module Alias
productsNamespace
Modules\ProductsTypecore
Priority15
Features
Product CRUD
Create, read, update, delete products
Inventory Management
Track stock with set/add/subtract operations
Low Stock Alerts
Configurable threshold-based alerts
Variants Support
Product variants with options and pricing
API Endpoints
# List products with filtering
GET /api/v1/products?status=active&search=keyword&per_page=20
# Create a product
POST /api/v1/products
{
"name": "Product Name",
"sku": "SKU-001",
"price": 999.00,
"cost_price": 500.00,
"track_inventory": true,
"stock_quantity": 100,
"low_stock_threshold": 10,
"status": "active",
"variants": [
{ "name": "Size L", "sku": "SKU-001-L", "price": 999.00, "stock_quantity": 50 }
]
}
# Get a single product
GET /api/v1/products/{id}
# Update a product
PATCH /api/v1/products/{id}
# Delete a product
DELETE /api/v1/products/{id}
# Search products
GET /api/v1/products/search?q=keyword
# Get low stock products
GET /api/v1/products/low-stock?threshold=10
# Adjust inventory
PATCH /api/v1/products/{id}/inventory
{
"quantity": 50,
"adjustment_type": "add", // "set", "add", "subtract"
"reason": "Restock from supplier"
}
# Bulk inventory update
POST /api/v1/products/bulk/inventory
{
"adjustments": [
{ "product_id": "uuid-1", "quantity": 100, "type": "set" },
{ "product_id": "uuid-2", "quantity": 10, "type": "subtract" }
]
}TypeScript Types
interface Product {
id: string;
sku: string | null;
name: string;
description: string | null;
source_module: string;
// Pricing
price: number;
compare_at_price: number | null;
cost_price: number | null;
profit_margin: number | null;
// Inventory
track_inventory: boolean;
stock_quantity: number;
low_stock_threshold: number;
is_low_stock: boolean;
is_out_of_stock: boolean;
// Status
status: 'active' | 'draft' | 'archived';
// Variants
variants?: ProductVariant[];
created_at: string;
updated_at: string;
}
interface ProductVariant {
id: string;
sku: string | null;
name: string;
price: number;
stock_quantity: number;
options: Record<string, string> | null;
}Frontend Hooks
import { useProducts, useProduct, useLowStockProducts } from '@modules/Products';
// List products with filtering
const { products, meta, loading, fetchProducts } = useProducts();
await fetchProducts({ status: 'active', search: 'keyword' });
// Single product operations
const { product, fetchProduct, setProduct } = useProduct(productId);
// Low stock alerts
const { products, fetchLowStock } = useLowStockProducts();
await fetchLowStock(10); // threshold