WC_Shipping_Zones
in package
Shipping zones class.
Table of Contents
- delete_zone() : mixed
- Delete a zone using it's ID
- get_shipping_method() : bool|WC_Shipping_Method
- Get shipping zone using it's ID.
- get_shipping_zones() : array<string|int, WC_Shipping_Zone>
- Retrieve Shipping_Zone data objects for the given zone_ids.
- get_zone() : WC_Shipping_Zone|bool
- Get shipping zone using it's ID
- get_zone_by() : WC_Shipping_Zone|bool
- Get shipping zone by an ID.
- get_zone_matching_package() : WC_Shipping_Zone
- Find a matching zone for a given package.
- get_zones() : array<string|int, mixed>
- Get shipping zones from the database.
- get_zones_with_order_conflict_warnings() : array<string|int, mixed>
- Get shipping zones from the database with admin warnings for zones that may not match because of their order.
- add_zone_order_conflict_warnings() : array<string|int, mixed>
- Add warnings to zones that are fully covered by a higher-priority zone.
- get_continent_code_for_location() : string
- Get the continent code for a country or state location.
- get_country_code_from_state_code() : string
- Get the country code from a state location code.
- get_shadowing_zone() : array<string|int, mixed>|null
- Get the first higher-priority zone that fully covers a zone.
- get_zone_locations_by_type() : array<string|int, mixed>
- Get zone locations for the requested location types.
- location_covers_location() : bool
- Check whether one location covers another location.
- zone_covers_zone() : bool
- Check whether a possible broader zone fully covers another zone.
- zone_has_postcode_locations() : bool
- Check whether a zone has postcode locations.
- zone_has_unsupported_non_postcode_locations() : bool
- Check whether a zone has non-postcode locations not understood by this warning helper.
Methods
delete_zone()
Delete a zone using it's ID
public
static delete_zone(int $zone_id) : mixed
Parameters
- $zone_id : int
-
Zone ID.
Tags
Return values
mixed —get_shipping_method()
Get shipping zone using it's ID.
public
static get_shipping_method(int $instance_id) : bool|WC_Shipping_Method
Parameters
- $instance_id : int
-
Instance ID.
Tags
Return values
bool|WC_Shipping_Method —get_shipping_zones()
Retrieve Shipping_Zone data objects for the given zone_ids.
public
static get_shipping_zones([array<string|int, mixed>|null $zone_ids = null ]) : array<string|int, WC_Shipping_Zone>
Parameters
- $zone_ids : array<string|int, mixed>|null = null
-
The zone_ids of the zones to retrieve. An empty array will return no results. Use null for all zones.
Return values
array<string|int, WC_Shipping_Zone> —get_zone()
Get shipping zone using it's ID
public
static get_zone(int $zone_id) : WC_Shipping_Zone|bool
Parameters
- $zone_id : int
-
Zone ID.
Tags
Return values
WC_Shipping_Zone|bool —get_zone_by()
Get shipping zone by an ID.
public
static get_zone_by([string $by = 'zone_id' ], int $id) : WC_Shipping_Zone|bool
Parameters
- $by : string = 'zone_id'
-
Get by 'zone_id' or 'instance_id'.
- $id : int
-
ID.
Tags
Return values
WC_Shipping_Zone|bool —get_zone_matching_package()
Find a matching zone for a given package.
public
static get_zone_matching_package(array<string|int, mixed> $package) : WC_Shipping_Zone
Parameters
- $package : array<string|int, mixed>
-
Shipping package.
Tags
Return values
WC_Shipping_Zone —get_zones()
Get shipping zones from the database.
public
static get_zones([string $context = 'admin' ]) : array<string|int, mixed>
Parameters
- $context : string = 'admin'
-
Getting shipping methods for what context. Valid values, admin, json.
Tags
Return values
array<string|int, mixed> — Array of arrays.get_zones_with_order_conflict_warnings()
Get shipping zones from the database with admin warnings for zones that may not match because of their order.
public
static get_zones_with_order_conflict_warnings([string $context = 'admin' ]) : array<string|int, mixed>
Parameters
- $context : string = 'admin'
-
Getting shipping methods for what context. Valid values, admin, json.
Tags
Return values
array<string|int, mixed> — Array of arrays.add_zone_order_conflict_warnings()
Add warnings to zones that are fully covered by a higher-priority zone.
private
static add_zone_order_conflict_warnings(array<string|int, mixed> $zones) : array<string|int, mixed>
Parameters
- $zones : array<string|int, mixed>
-
Shipping zones.
Tags
Return values
array<string|int, mixed> — Shipping zones with order conflict warnings.get_continent_code_for_location()
Get the continent code for a country or state location.
private
static get_continent_code_for_location(object $location) : string
Parameters
- $location : object
-
Location.
Tags
Return values
string — Continent code, or an empty string.get_country_code_from_state_code()
Get the country code from a state location code.
private
static get_country_code_from_state_code(string $state_code) : string
Parameters
- $state_code : string
-
State location code.
Tags
Return values
string — Country code.get_shadowing_zone()
Get the first higher-priority zone that fully covers a zone.
private
static get_shadowing_zone(array<string|int, mixed> $zone, array<string|int, mixed> $higher_priority_zones) : array<string|int, mixed>|null
Parameters
- $zone : array<string|int, mixed>
-
Zone to check.
- $higher_priority_zones : array<string|int, mixed>
-
Higher-priority zones.
Tags
Return values
array<string|int, mixed>|null — Shadowing zone, or null when none exists.get_zone_locations_by_type()
Get zone locations for the requested location types.
private
static get_zone_locations_by_type(array<string|int, mixed> $zone, array<string|int, mixed> $location_types) : array<string|int, mixed>
Parameters
- $zone : array<string|int, mixed>
-
Shipping zone.
- $location_types : array<string|int, mixed>
-
Location types.
Tags
Return values
array<string|int, mixed> — Zone locations.location_covers_location()
Check whether one location covers another location.
private
static location_covers_location(object $possible_broader_location, object $location) : bool
Parameters
- $possible_broader_location : object
-
Possible broader location.
- $location : object
-
Location to check.
Tags
Return values
bool — Whether the possible broader location covers the location.zone_covers_zone()
Check whether a possible broader zone fully covers another zone.
private
static zone_covers_zone(array<string|int, mixed> $possible_broader_zone, array<string|int, mixed> $zone) : bool
Parameters
- $possible_broader_zone : array<string|int, mixed>
-
Possible broader zone.
- $zone : array<string|int, mixed>
-
Zone to check.
Tags
Return values
bool — Whether the possible broader zone fully covers the zone.zone_has_postcode_locations()
Check whether a zone has postcode locations.
private
static zone_has_postcode_locations(array<string|int, mixed> $zone) : bool
Parameters
- $zone : array<string|int, mixed>
-
Shipping zone.
Tags
Return values
bool — Whether the zone has postcode locations.zone_has_unsupported_non_postcode_locations()
Check whether a zone has non-postcode locations not understood by this warning helper.
private
static zone_has_unsupported_non_postcode_locations(array<string|int, mixed> $zone) : bool
Parameters
- $zone : array<string|int, mixed>
-
Shipping zone.
