WP Manifestindependent plugin directory
manifest / ecommerce / woocommerce-multiwarehouse-plugin

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

★ 0stars
0forks

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.zip

Multi-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

  1. Download the plugin ZIP file
  2. Navigate to Plugins → Add New → Upload Plugin in your WordPress admin
  3. Upload the multi-warehouse.zip file
  4. Activate the plugin
  5. Configure settings under Warehouses → Settings

Quick Start

1. Create Warehouses

  1. Navigate to Warehouses → Add New
  2. Enter warehouse name and full address
  3. Click "Geocode Address" to automatically populate coordinates
  4. Set status to "Active"
  5. Save warehouse

2. Configure Inventory

  1. Edit any product
  2. Scroll to "Warehouse Inventory" panel
  3. Set stock quantities for each active warehouse
  4. Save product

3. Configure Settings

  1. Navigate to Warehouses → Settings
  2. Set fallback shipping fee (optional)
  3. 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

  1. Creating Warehouses: Use the Warehouse post type to create new warehouses
  2. Geocoding: Addresses are automatically geocoded using OpenStreetMap Nominatim API
  3. Active Status: Only active warehouses participate in stock allocation

Inventory Management

  1. Product Setup: Each product can have stock quantities set per warehouse
  2. Stock Calculation: Total stock is the sum across all active warehouses
  3. Real-time Updates: Stock changes are immediately reflected in the frontend

Checkout Process

  1. Address Geocoding: Customer shipping address is geocoded
  2. Distance Calculation: Distance to all active warehouses is calculated
  3. Warehouse Selection: Closest warehouse with sufficient stock is selected
  4. Fallback Logic: If closest warehouse lacks stock, next closest is used
  5. Fee Application: Fallback shipping fee applied when secondary warehouse is used

Catalog Filtering

  1. Shop Page Filter: Dropdown filter to show products from specific warehouses
  2. Shortcode Support: Use [warehouse_filter] to display filter anywhere
  3. 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)