PHP Класс WC_Shipping_Zone

Controls a single zone, loads shipping methods, and registers them for use.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$data array Zone Data
$id integer | null Zone ID

Открытые методы

Метод Описание
__construct ( integer | object $zone = null ) Constructor for zones.
add_location ( string $code, string $type ) Add location (state or postcode) to a zone.
add_shipping_method ( string $type ) : integer Add a shipping method to this zone.
clear_locations ( array | string $types = ['postcode', 'state', 'country', 'continent'] ) Clear all locations for this zone.
delete_shipping_method ( integer $instance_id ) : True Delete a shipping method from a zone.
get_formatted_location ( integer $max = 10, string $context = 'view' ) : string Return a text string representing what this zone is for.
get_shipping_methods ( $enabled_only = false ) : array Get shipping methods linked to this zone.
get_zone_locations ( string $context = 'view' ) : array Get zone locations.
get_zone_name ( string $context = 'view' ) : string Get zone name.
get_zone_order ( string $context = 'view' ) : integer Get zone order.
is_valid_location_type ( string $type ) : boolean Is passed location type valid?
save ( ) : integer Save zone data to the database.
set_locations ( array $locations = [] ) Set locations.
set_zone_locations ( $locations ) Set zone locations.
set_zone_name ( string $set ) Set zone name.
set_zone_order ( integer $set ) Set zone order.

Защищенные методы

Метод Описание
generate_zone_name ( ) : string Generate a zone name based on location.
get_hook_prefix ( ) : string Prefix for action and filter hooks on data.

Приватные методы

Метод Описание
location_is_continent ( object $location ) : boolean Location type detection.
location_is_country ( object $location ) : boolean Location type detection.
location_is_postcode ( object $location ) : boolean Location type detection.
location_is_state ( object $location ) : boolean Location type detection.

Описание методов

__construct() публичный Метод

Constructor for zones.
public __construct ( integer | object $zone = null )
$zone integer | object Zone ID to load from the DB or zone object.

add_location() публичный Метод

Add location (state or postcode) to a zone.
public add_location ( string $code, string $type )
$code string
$type string state or postcode

add_shipping_method() публичный Метод

Add a shipping method to this zone.
public add_shipping_method ( string $type ) : integer
$type string shipping method type
Результат integer new instance_id, 0 on failure

clear_locations() публичный Метод

Clear all locations for this zone.
public clear_locations ( array | string $types = ['postcode', 'state', 'country', 'continent'] )
$types array | string of location to clear

delete_shipping_method() публичный Метод

Delete a shipping method from a zone.
public delete_shipping_method ( integer $instance_id ) : True
$instance_id integer
Результат True on success, false on failure

generate_zone_name() защищенный Метод

Generate a zone name based on location.
protected generate_zone_name ( ) : string
Результат string

get_formatted_location() публичный Метод

Return a text string representing what this zone is for.
public get_formatted_location ( integer $max = 10, string $context = 'view' ) : string
$max integer
$context string
Результат string

get_hook_prefix() защищенный Метод

Prefix for action and filter hooks on data.
С версии: 2.7.0
protected get_hook_prefix ( ) : string
Результат string

get_shipping_methods() публичный Метод

Get shipping methods linked to this zone.
public get_shipping_methods ( $enabled_only = false ) : array
Результат array of objects

get_zone_locations() публичный Метод

Get zone locations.
public get_zone_locations ( string $context = 'view' ) : array
$context string
Результат array of zone objects

get_zone_name() публичный Метод

Get zone name.
public get_zone_name ( string $context = 'view' ) : string
$context string
Результат string

get_zone_order() публичный Метод

Get zone order.
public get_zone_order ( string $context = 'view' ) : integer
$context string
Результат integer

is_valid_location_type() публичный Метод

Is passed location type valid?
public is_valid_location_type ( string $type ) : boolean
$type string
Результат boolean

save() публичный Метод

Save zone data to the database.
public save ( ) : integer
Результат integer

set_locations() публичный Метод

Set locations.
public set_locations ( array $locations = [] )
$locations array Array of locations

set_zone_locations() публичный Метод

Set zone locations.
С версии: 2.7.0
public set_zone_locations ( $locations )

set_zone_name() публичный Метод

Set zone name.
public set_zone_name ( string $set )
$set string

set_zone_order() публичный Метод

Set zone order.
public set_zone_order ( integer $set )
$set integer

Описание свойств

$data защищенное свойство

Zone Data
protected array $data
Результат array

$id защищенное свойство

Zone ID
protected int|null $id
Результат integer | null