Multi-Warehouse Inventory Management
Extends WooCommerce to support multi-warehouse inventory management with automatic warehouse selection based on customer shipping address.
by Multi-Warehouse Team · github.com/upgernaut/woocommerce-multiwarehouse-plugin
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/upgernaut/woocommerce-multiwarehouse-plugin/archive/refs/heads/master.zipMulti-Warehouse Inventory Management for WooCommerce
A comprehensive WordPress plugin that extends WooCommerce to support multi-warehouse inventory management with automatic warehouse selection based on customer shipping address.
Features
- Multi-Warehouse Support: Create and manage multiple warehouses with geocoded addresses
- Automatic Warehouse Selection: Intelligent selection based on customer proximity and stock availability
- Stock Management: Per-warehouse inventory tracking with automatic stock calculation
- Distance-Based Logic: Uses OpenStreetMap Nominatim API for geocoding and Haversine formula for distance calculation
- Additional Shipping Fees: Apply additional fees when secondary warehouses are used
- Catalog Filtering: Filter products by warehouse availability
- Overselling Prevention: Transaction-safe stock reduction with race condition protection
- Admin Interface: Comprehensive admin panels for warehouse and inventory management
Requirements
- WordPress 5.0+
- WooCommerce 5.0+
- PHP 7.4+
Installation
- Download the plugin ZIP file
- Navigate to Plugins → Add New → Upload Plugin in your WordPress admin
- Upload the
multi-warehouse.zipfile - Activate the plugin
- Configure settings under Warehouses → Settings
Quick Start
1. Create Warehouses
- Navigate to Warehouses → Add New
- Enter warehouse name and full address
- Click "Geocode Address" to automatically populate coordinates
- Set status to "Active"
- Save warehouse
2. Configure Inventory
- Edit any product
- Scroll to "Warehouse Inventory" panel
- Set stock quantities for each active warehouse
- Save product
3. Configure Settings
- Navigate to Warehouses → Settings
- Set fallback shipping fee (optional)
- Save settings
Architecture
Plugin Structure
multi-warehouse/
├── multi-warehouse.php # Main plugin file
├── hpos-compatibility-test.php # HPOS compatibility testing
├── includes/
│ ├── class-warehouse-cpt.php # Warehouse custom post type
│ ├── class-inventory-table.php # Database operations
│ ├── class-product-admin.php # Product admin interface
│ ├── class-stock-manager.php # Stock calculation and management
│ ├── class-distance-service.php # Geocoding and distance calculation
│ ├── class-checkout-handler.php # Checkout logic and warehouse selection
│ ├── class-catalog-filter.php # Shop page filtering
│ ├── class-frontend-display.php # Frontend display functionality
│ └── class-settings.php # Plugin settings
├── assets/
│ ├── js/
│ │ ├── warehouse-filter.js # Frontend filtering JavaScript
│ │ └── warehouse-check.js # Warehouse availability checking
│ └── css/
│ ├── admin.css # Admin styling
│ └── frontend.css # Frontend styling
└── README.md # This file
Database Schema
The plugin creates a custom table wp_warehouse_inventory:
CREATE TABLE wp_warehouse_inventory (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
product_id bigint(20) unsigned NOT NULL,
warehouse_id bigint(20) unsigned NOT NULL,
stock_quantity int(11) NOT NULL DEFAULT 0,
created_at datetime DEFAULT CURRENT_TIMESTAMP,
updated_at datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY unique_product_warehouse (product_id, warehouse_id),
KEY product_id (product_id),
KEY warehouse_id (warehouse_id),
KEY stock_quantity (stock_quantity)
);
Key Classes
- Multi_Warehouse_CPT: Manages warehouse custom post type and geocoding
- Multi_Warehouse_Inventory_Table: Handles all database operations
- Multi_Warehouse_Stock_Manager: Overrides WooCommerce stock functions
- Multi_Warehouse_Distance_Service: Geocoding and distance calculations
- Multi_Warehouse_Checkout_Handler: Warehouse selection at checkout
- Multi_Warehouse_Catalog_Filter: Shop page filtering functionality
- Multi_Warehouse_Frontend_Display: Frontend display and user interface elements
Usage
Warehouse Management
- Creating Warehouses: Use the Warehouse post type to create new warehouses
- Geocoding: Addresses are automatically geocoded using OpenStreetMap Nominatim API
- Active Status: Only active warehouses participate in stock allocation
Inventory Management
- Product Setup: Each product can have stock quantities set per warehouse
- Stock Calculation: Total stock is the sum across all active warehouses
- Real-time Updates: Stock changes are immediately reflected in the frontend
Checkout Process
- Address Geocoding: Customer shipping address is geocoded
- Distance Calculation: Distance to all active warehouses is calculated
- Warehouse Selection: Closest warehouse with sufficient stock is selected
- Fallback Logic: If closest warehouse lacks stock, next closest is used
- Fee Application: Fallback shipping fee applied when secondary warehouse is used
Catalog Filtering
- Shop Page Filter: Dropdown filter to show products from specific warehouses
- Shortcode Support: Use
[warehouse_filter]to display filter anywhere - Stock Badges: Show warehouse availability on product pages
API Integration
OpenStreetMap Nominatim
The plugin uses the free OpenStreetMap Nominatim API for:
- Warehouse address geocoding
- Customer address geocoding
- Coordinate-based distance calculations
Rate Limits: Nominatim has usage limits. The plugin implements caching to minimize API calls.
Caching Strategy
- Geocoding results are cached for 1 hour
- WordPress object cache is utilized
- In-memory caching during request processing
Configuration Options
Additional Shipping Fee
Set a global fallback shipping fee that applies when:
- Closest warehouse doesn't have sufficient stock
- Products are shipped from secondary warehouses
- Fee is displayed as a separate cart fee
Warehouse Status
- Active: Participates in stock allocation and distance calculation
- Inactive: Ignored in all calculations (but data preserved)