WooShippingZoneLocation class

WooCommerce Shipping Zone Location Model

Represents a geographical location within a shipping zone that determines which customers are eligible for the shipping methods and rates defined within that zone based on their location.

Shipping Zone Location Structure

A shipping zone location consists of key components:

  • Location Code: The specific geographical identifier
  • Location Type: The type of geographical area (country, state, postcode, continent)
  • Coverage Definition: Determines which customers are covered by the zone

Location Types

  • Country: Entire countries (e.g., 'US', 'CA', 'GB')
  • State: Specific states/provinces within countries
  • Postcode: Specific postal codes or postal code ranges
  • Continent: Entire continents (e.g., 'NA', 'EU', 'AS')

Example Usage

// Create a country location
final location = WooShippingZoneLocation(
  code: 'US',
  type: 'country',
);

// Create from API response
final location = WooShippingZoneLocation.fromJson({
  'code': 'US',
  'type': 'country'
});

// Access properties
print('${location.type}: ${location.code}');

// Convert to JSON
final json = location.toJson();

Constructors

WooShippingZoneLocation({String? code, String? type})
Creates a new WooShippingZoneLocation instance
WooShippingZoneLocation.fake()
Creates a fake shipping zone location for testing and development
factory
WooShippingZoneLocation.fromJson(Map<String, dynamic> json)
Creates a WooShippingZoneLocation from JSON data
factory

Properties

code String?
Geographical location code
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String?
Type of geographical location
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the location to JSON format
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited