Locations represent physical places where you store inventory and ship orders from: warehouses, retail stores, fulfillment centers, or even your apartment. Each location has its own address and can track stock independently, so a product can have 50 units in your Paris warehouse and 20 in your New York store.
When Shopper is first installed, the setup wizard creates a default location using your store’s address. All stock mutations target this location unless you specify another one. If your business ships from multiple places, you can add more locations and assign stock to each one.
Model
The model used is Shopper\Core\Models\Inventory. It implements Shopper\Core\Models\Contracts\Inventory and is configurable via config/shopper/models.php.
Extending the Model
To add custom behavior, extend the model and update your configuration:
Update config/shopper/models.php:
Database Schema
Relationships
Country
Each location belongs to a country:
Inventory Histories
Every stock mutation (increase, decrease, set) on any product or variant creates an InventoryHistory record tied to a specific location. This is how Shopper tracks stock per location.
Query Scopes
The default scope returns the location marked as the default inventory. This is the location used by InitialQuantityInventory when setting stock during product creation.
How Locations Connect to Stock
When you call mutateStock(), decreaseStock(), or setStock() on a product or variant, you pass an $inventoryId. This ties the stock mutation to a specific location:
To get stock for a product at a specific location:
To batch-load stock for a specific location across multiple products (avoiding N+1):
Creating Locations
To create a new warehouse location:
Retrieving Locations
To get the default location:
To get all locations ordered by priority:
To find the nearest location to a customer (if latitude/longitude are set):
Default Location
The default location is used as the origin address for shipping calculations and as the fallback when stock operations do not specify a location. Only one location can be the default.
Deleting a location removes all inventory history records tied to it. This affects stock levels for every product that had stock in that location. Proceed with caution.
Components
To customize the admin UI for location management:
Location-related components in config/shopper/components/setting.php: