Model
The model used isShopper\Core\Models\Zone. It uses the HasSlug trait for automatic slug generation. The model is not configurable via config/shopper/models.php.
Database Schema
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | bigint | no | auto | Primary key |
name | string | no | - | Zone name (unique) |
slug | string | yes | auto | URL-friendly identifier (unique) |
code | string | yes | null | Short code identifier (unique) |
is_enabled | boolean | no | false | Zone visibility |
currency_id | bigint | yes | null | FK to currencies table |
metadata | jsonb | yes | null | Additional custom data |
created_at | timestamp | yes | null | Creation timestamp |
updated_at | timestamp | yes | null | Last update timestamp |
Pivot Table
Thezone_has_relations pivot table connects zones to countries, carriers, payment methods, and collections through a polymorphic relationship.
| Column | Type | Description |
|---|---|---|
zone_id | bigint | FK to zone |
zonable_type | string | Morph type (Country, Carrier, PaymentMethod, Collection) |
zonable_id | bigint | FK to the related model |
Relationships
Currency
Each zone is associated with one currency. This determines which currency is used for pricing and checkout in that zone.Countries
Zones group multiple countries together. When a customer enters a shipping address, Shopper resolves the zone by matching the country.Carriers
Carriers (shipping providers) are scoped to zones. A carrier available in Europe may not be available in North America.Payment Methods
Payment methods are scoped to zones. For example, iDEAL is only available in the Netherlands zone.Shipping Options
Each zone has shipping options (carrier options with rates) available at checkout:Collections
Collections can be scoped to specific zones for region-specific merchandising:Query Scopes
Theenabled scope filters zones that are active:
Computed Attributes
The Zone model provides computed attributes that return comma-separated names for related entities:HasZones Trait
Models that can be scoped to zones use theHasZones trait. This is already applied to PaymentMethod, Carrier, and Collection models.
Creating Zones
To create a zone for the European market:Retrieving Zones
To find the zone for a customer’s shipping address:Components
The zone management components are part of the settings configuration. To customize:config/shopper/components/setting.php: