PHP Класс WC_Shipping_Method

Extended by shipping methods to handle shipping calculations etc.
Автор: WooThemes
Наследование: extends WC_Settings_API
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$availability string No longer useful for instance based shipping methods.
$countries array No longer useful for instance based shipping methods.
$enabled string yes or no based on whether the method is enabled.
$fee string Fee for the method (if applicable).
$id string Unique ID for the shipping method - must be set.
$instance_form_fields array Instance form fields.
$instance_id integer Instance ID if used.
$instance_settings array Instance settings.
$method_description string Method description.
$method_title string Method title.
$minimum_fee string Minimum fee for the method (if applicable).
$rates array This is an array of rates - methods must populate this array to register shipping costs.
$supports array - settings Non-instance settings screens. Enabled by default for BW compatibility with methods before instances existed. - instance-settings-modal Allows the instance settings to be loaded within a modal in the zones UI.
$tax_status string If 'taxable' tax will be charged for this method (if applicable).
$title string Shipping method title for the frontend.

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

Метод Описание
__construct ( integer $instance_id ) Constructor.
add_rate ( array $args = [] ) Add a shipping rate. If taxes are not set they will be calculated based on cost.
admin_options ( ) Output the shipping settings screen.
calculate_shipping ( $package = [] ) Called to calculate shipping rates for this method. Rates can be added using the add_rate() method.
get_admin_options_html ( ) : string Return admin options as a html string.
get_fee ( string | float $fee, float $total ) : float Get fee to add to shipping cost.
get_instance_form_fields ( ) : array Get settings fields for instances of this shipping method (within zones).
get_instance_id ( ) : integer Return the shipping method instance ID.
get_instance_option ( string $key, mixed $empty_value = null ) : mixed Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
get_instance_option_key ( ) : string Return the name of the option in the WP DB.
get_method_description ( ) : string Return the shipping method description.
get_method_title ( ) : string Return the shipping method title.
get_option ( string $key, mixed $empty_value = null ) : mixed get_option function.
get_rate_id ( string $suffix = '' ) : string Returns a rate ID based on this methods ID and instance, with an optional suffix if distinguishing between multiple rates.
get_rates_for_package ( object $package ) : array Return calculated rates for a package.
get_title ( ) : string Return the shipping title which is user set.
has_settings ( ) : boolean Does this method have a settings page?
init_instance_settings ( ) Initialise Settings for instances.
is_available ( array $package ) : boolean Is this method available?
is_enabled ( ) : boolean Whether or not this method is enabled in settings.
is_taxable ( ) : boolean Whether or not we need to calculate tax on top of the shipping rate.
process_admin_options ( ) : boolean Processes and saves options.
supports ( $feature ) : boolean Check if a shipping method supports a given feature.

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

Метод Описание
get_taxes_per_item ( array $costs ) : array Calc taxes per item being shipping in costs array.

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

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

Constructor.
public __construct ( integer $instance_id )
$instance_id integer

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

Add a shipping rate. If taxes are not set they will be calculated based on cost.
public add_rate ( array $args = [] )
$args array (default: array())

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

Output the shipping settings screen.
public admin_options ( )

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

Called to calculate shipping rates for this method. Rates can be added using the add_rate() method.
public calculate_shipping ( $package = [] )

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

Return admin options as a html string.
public get_admin_options_html ( ) : string
Результат string

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

Get fee to add to shipping cost.
public get_fee ( string | float $fee, float $total ) : float
$fee string | float
$total float
Результат float

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

Should be overridden by shipping methods to add options.
С версии: 2.6.0
public get_instance_form_fields ( ) : array
Результат array

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

Return the shipping method instance ID.
С версии: 2.6.0
public get_instance_id ( ) : integer
Результат integer

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

Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
public get_instance_option ( string $key, mixed $empty_value = null ) : mixed
$key string
$empty_value mixed
Результат mixed The value specified for the option or a default value for the option.

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

Return the name of the option in the WP DB.
С версии: 2.6.0
public get_instance_option_key ( ) : string
Результат string

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

Return the shipping method description.
С версии: 2.6.0
public get_method_description ( ) : string
Результат string

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

Return the shipping method title.
С версии: 2.6.0
public get_method_title ( ) : string
Результат string

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

Gets and option from the settings API, using defaults if necessary to prevent undefined notices.
public get_option ( string $key, mixed $empty_value = null ) : mixed
$key string
$empty_value mixed
Результат mixed The value specified for the option or a default value for the option.

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

Returns a rate ID based on this methods ID and instance, with an optional suffix if distinguishing between multiple rates.
С версии: 2.6.0
public get_rate_id ( string $suffix = '' ) : string
$suffix string
Результат string

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

Return calculated rates for a package.
С версии: 2.6.0
public get_rates_for_package ( object $package ) : array
$package object
Результат array

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

Calc taxes per item being shipping in costs array.
С версии: 2.6.0
protected get_taxes_per_item ( array $costs ) : array
$costs array
Результат array of taxes

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

Return the shipping title which is user set.
public get_title ( ) : string
Результат string

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

Does this method have a settings page?
public has_settings ( ) : boolean
Результат boolean

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

Initialise Settings for instances.
С версии: 2.6.0

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

Is this method available?
public is_available ( array $package ) : boolean
$package array
Результат boolean

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

Whether or not this method is enabled in settings.
С версии: 2.6.0
public is_enabled ( ) : boolean
Результат boolean

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

Whether or not we need to calculate tax on top of the shipping rate.
public is_taxable ( ) : boolean
Результат boolean

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

If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
С версии: 2.6.0
public process_admin_options ( ) : boolean
Результат boolean was anything saved?

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

Methods should override this to declare support (or lack of support) for a feature.
public supports ( $feature ) : boolean
$feature string The name of a feature to test support for.
Результат boolean True if the shipping method supports the feature, false otherwise.

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

$availability публичное свойство

No longer useful for instance based shipping methods.
Устаревший: 2.6.0
public string $availability
Результат string

$countries публичное свойство

No longer useful for instance based shipping methods.
Устаревший: 2.6.0
public array $countries
Результат array

$enabled публичное свойство

yes or no based on whether the method is enabled.
public string $enabled
Результат string

$fee публичное свойство

Fee for the method (if applicable).
public string $fee
Результат string

$id публичное свойство

Unique ID for the shipping method - must be set.
public string $id
Результат string

$instance_form_fields публичное свойство

Instance form fields.
public array $instance_form_fields
Результат array

$instance_id публичное свойство

Instance ID if used.
public int $instance_id
Результат integer

$instance_settings публичное свойство

Instance settings.
public array $instance_settings
Результат array

$method_description публичное свойство

Method description.
public string $method_description
Результат string

$method_title публичное свойство

Method title.
public string $method_title
Результат string

$minimum_fee публичное свойство

Minimum fee for the method (if applicable).
public string $minimum_fee
Результат string

$rates публичное свойство

This is an array of rates - methods must populate this array to register shipping costs.
public array $rates
Результат array

$supports публичное свойство

- settings Non-instance settings screens. Enabled by default for BW compatibility with methods before instances existed. - instance-settings-modal Allows the instance settings to be loaded within a modal in the zones UI.
public array $supports
Результат array

$tax_status публичное свойство

If 'taxable' tax will be charged for this method (if applicable).
public string $tax_status
Результат string

$title публичное свойство

Shipping method title for the frontend.
public string $title
Результат string