PHP Класс WC_Tax

Автор: WooThemes
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$precision integer Precision.
$round_at_subtotal boolean Round at subtotal.

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

Метод Описание
_delete_tax_rate ( integer $tax_rate_id ) Delete a tax rate from the database.
_get_tax_rate ( integer $tax_rate_id, string $output_type = ARRAY_A ) : array Get tax rate.
_insert_tax_rate ( array $tax_rate ) : integer Insert a new tax rate.
_update_tax_rate ( integer $tax_rate_id, array $tax_rate ) Update a tax rate.
_update_tax_rate_cities ( integer $tax_rate_id, string $cities ) : string Update cities for a tax rate in the DB.
_update_tax_rate_postcodes ( integer $tax_rate_id, string $postcodes ) : string Update postcodes for a tax rate in the DB.
calc_exclusive_tax ( float $price, array $rates ) : array Calc tax from exclusive price.
calc_inclusive_tax ( float $price, array $rates ) : array Calc tax from inclusive price.
calc_shipping_tax ( $price, $rates ) : array Calculate the shipping tax using a passed array of rates.
calc_tax ( float $price, array $rates, boolean $price_includes_tax = false, boolean $suppress_rounding = false ) : array Calculate tax for a line.
find_rates ( array $args = [] ) : array Searches for all matching country/state/postcode tax rates.
find_shipping_rates ( array $args = [] ) : array Searches for all matching country/state/postcode tax rates.
format_tax_rate_class ( string $class ) : string format the class.
get_base_tax_rates ( $tax_class = '' ) : array Get's an array of matching rates for the shop's base country.
get_rate_code ( mixed $key_or_rate ) : string Get a rates code. Code is made up of COUNTRY-STATE-NAME-Priority. E.g GB-VAT-1, US-AL-TAX-1.
get_rate_label ( mixed $key_or_rate ) : string Return a given rates label.
get_rate_percent ( mixed $key_or_rate ) : string Return a given rates percent.
get_rates ( string $tax_class = '' ) : array Get's an array of matching rates for a tax class.
get_rates_for_tax_class ( string $tax_class ) : array | null | object Used by admin settings page.
get_shipping_tax_rates ( $tax_class = null ) : mixed Gets an array of matching shipping tax rates for a given class.
get_shop_base_rate ( $tax_class = '' ) : array Alias for get_base_tax_rates().
get_tax_classes ( ) : array Get store tax classes.
get_tax_location ( $tax_class = '' ) : array Get the customer tax location based on their status and the current page.
get_tax_total ( $taxes ) : float Round tax lines and return the sum.
init ( ) Load options.
is_compound ( $key ) : boolean Return true/false depending on if a rate is a compound rate.
maybe_remove_tax_class_rates ( string $old_value, string $value ) When the woocommerce_tax_classes option is changed, remove any orphan rates.
round ( $in ) : double Round to precision.

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

Метод Описание
_update_tax_rate_locations ( integer $tax_rate_id, $values, string $type ) : string Updates locations (postcode and city).
format_tax_rate ( double $rate ) : string format the rate.
format_tax_rate_city ( string $city ) : string format the city.
format_tax_rate_country ( string $country ) : string format the country.
format_tax_rate_name ( string $name ) : string format the tax rate name.
format_tax_rate_priority ( string $priority ) : integer format the priority.
format_tax_rate_state ( string $state ) : string format the state.
get_matched_tax_rates ( string $country, string $state, string $postcode, string $city, string $tax_class ) : array Loop through a set of tax rates and get the matching rates (1 per priority).
precision ( float $price ) : float Multiply cost by pow precision.
prepare_tax_rate ( array $tax_rate ) : array Prepare and format tax rate for DB insertion.
remove_precision ( float $price ) : float Divide cost by pow precision.
sort_rates ( array $rates ) : array Logical sort order for tax rates based on the following in order of priority: - Priority - County code - State code
sort_rates_callback ( $rate1, $rate2 ) Does the sort comparison.

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

_delete_tax_rate() публичный статический Метод

Internal use only.
С версии: 2.3.0
public static _delete_tax_rate ( integer $tax_rate_id )
$tax_rate_id integer

_get_tax_rate() публичный статический Метод

Internal use only.
С версии: 2.5.0
public static _get_tax_rate ( integer $tax_rate_id, string $output_type = ARRAY_A ) : array
$tax_rate_id integer
$output_type string
Результат array

_insert_tax_rate() публичный статический Метод

Internal use only.
С версии: 2.3.0
public static _insert_tax_rate ( array $tax_rate ) : integer
$tax_rate array
Результат integer tax rate id

_update_tax_rate() публичный статический Метод

Internal use only.
С версии: 2.3.0
public static _update_tax_rate ( integer $tax_rate_id, array $tax_rate )
$tax_rate_id integer
$tax_rate array

_update_tax_rate_cities() публичный статический Метод

Internal use only.
С версии: 2.3.0
public static _update_tax_rate_cities ( integer $tax_rate_id, string $cities ) : string
$tax_rate_id integer
$cities string
Результат string

_update_tax_rate_postcodes() публичный статический Метод

Internal use only.
С версии: 2.3.0
public static _update_tax_rate_postcodes ( integer $tax_rate_id, string $postcodes ) : string
$tax_rate_id integer
$postcodes string String of postcodes separated by ; characters
Результат string

calc_exclusive_tax() публичный статический Метод

Calc tax from exclusive price.
public static calc_exclusive_tax ( float $price, array $rates ) : array
$price float
$rates array
Результат array

calc_inclusive_tax() публичный статический Метод

Calc tax from inclusive price.
public static calc_inclusive_tax ( float $price, array $rates ) : array
$price float
$rates array
Результат array

calc_shipping_tax() публичный статический Метод

Calculate the shipping tax using a passed array of rates.
public static calc_shipping_tax ( $price, $rates ) : array
Результат array

calc_tax() публичный статический Метод

Calculate tax for a line.
public static calc_tax ( float $price, array $rates, boolean $price_includes_tax = false, boolean $suppress_rounding = false ) : array
$price float Price to calc tax on
$rates array Rates to apply
$price_includes_tax boolean Whether the passed price has taxes included
$suppress_rounding boolean Whether to suppress any rounding from taking place
Результат array Array of rates + prices after tax

find_rates() публичный статический Метод

Searches for all matching country/state/postcode tax rates.
public static find_rates ( array $args = [] ) : array
$args array
Результат array

find_shipping_rates() публичный статический Метод

Searches for all matching country/state/postcode tax rates.
public static find_shipping_rates ( array $args = [] ) : array
$args array
Результат array

format_tax_rate_class() публичный статический Метод

format the class.
public static format_tax_rate_class ( string $class ) : string
$class string
Результат string

get_base_tax_rates() публичный статический Метод

Get's an array of matching rates for the shop's base country.
public static get_base_tax_rates ( $tax_class = '' ) : array
Результат array

get_rate_code() публичный статический Метод

Get a rates code. Code is made up of COUNTRY-STATE-NAME-Priority. E.g GB-VAT-1, US-AL-TAX-1.
public static get_rate_code ( mixed $key_or_rate ) : string
$key_or_rate mixed Tax rate ID, or the db row itself in object format
Результат string

get_rate_label() публичный статический Метод

Return a given rates label.
public static get_rate_label ( mixed $key_or_rate ) : string
$key_or_rate mixed Tax rate ID, or the db row itself in object format
Результат string

get_rate_percent() публичный статический Метод

Return a given rates percent.
public static get_rate_percent ( mixed $key_or_rate ) : string
$key_or_rate mixed Tax rate ID, or the db row itself in object format
Результат string

get_rates() публичный статический Метод

Get's an array of matching rates for a tax class.
public static get_rates ( string $tax_class = '' ) : array
$tax_class string
Результат array

get_rates_for_tax_class() публичный статический Метод

Used by admin settings page.
public static get_rates_for_tax_class ( string $tax_class ) : array | null | object
$tax_class string
Результат array | null | object

get_shipping_tax_rates() публичный статический Метод

Gets an array of matching shipping tax rates for a given class.
public static get_shipping_tax_rates ( $tax_class = null ) : mixed
Результат mixed

get_shop_base_rate() публичный статический Метод

Alias for get_base_tax_rates().
Устаревший: 2.3
public static get_shop_base_rate ( $tax_class = '' ) : array
Результат array

get_tax_classes() публичный статический Метод

Get store tax classes.
public static get_tax_classes ( ) : array
Результат array

get_tax_location() публичный статический Метод

Used by get_rates(), get_shipping_rates().
public static get_tax_location ( $tax_class = '' ) : array
$tax_class string Optional, passed to the filter for advanced tax setups.
Результат array

get_tax_total() публичный статический Метод

Round tax lines and return the sum.
public static get_tax_total ( $taxes ) : float
Результат float

init() публичный статический Метод

Load options.
public static init ( )

is_compound() публичный статический Метод

Return true/false depending on if a rate is a compound rate.
public static is_compound ( $key ) : boolean
Результат boolean

maybe_remove_tax_class_rates() публичный статический Метод

When the woocommerce_tax_classes option is changed, remove any orphan rates.
public static maybe_remove_tax_class_rates ( string $old_value, string $value )
$old_value string
$value string

round() публичный статический Метод

Filter example: to return rounding to .5 cents you'd use: function euro_5cent_rounding( $in ) { return round( $in / 5, 2 ) * 5; } add_filter( 'woocommerce_tax_round', 'euro_5cent_rounding' );
public static round ( $in ) : double
Результат double

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

$precision публичное статическое свойство

Precision.
public static int $precision
Результат integer

$round_at_subtotal публичное статическое свойство

Round at subtotal.
public static bool $round_at_subtotal
Результат boolean