WooCommerce Code Reference

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
since
2.6.0
Return values
mixed

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_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
since
2.6.0
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
since
11.1.0
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
since
11.1.0
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
since
11.1.0
Return values
stringContinent 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
since
11.1.0
Return values
stringCountry 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
since
11.1.0
Return values
array<string|int, mixed>|nullShadowing 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
since
11.1.0
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
since
11.1.0
Return values
boolWhether 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
since
11.1.0
Return values
boolWhether 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
since
11.1.0
Return values
boolWhether 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.

Tags
since
11.1.0
Return values
boolWhether the zone has unsupported non-postcode locations.