Class WC_Tax

Performs tax calculations and loads tax rates.

Package: WooCommerce\Classes
Category: Class
Author: WooThemes
Version: 2.0.0
Class: WC_Tax
Located at includes/class-wc-tax.php

Methods summary

public
# __construct( )

__construct function.

__construct function.

public array
# calc_tax( float $price, array $rates, boolean $price_includes_tax = false, boolean $suppress_rounding = false )

Calculate tax for a line

Calculate tax for a line

Parameters

$price
float
$price Price to calc tax on
$rates
array
$rates Rates to apply
$price_includes_tax
boolean
$price_includes_tax Whether the passed price has taxes included
$suppress_rounding
boolean
$suppress_rounding Whether to suppress any rounding from taking place

Returns

array
Array of rates + prices after tax
public array
# calc_shipping_tax( float $price, array $rates )

Calculate the shipping tax using a passed array of rates.

Calculate the shipping tax using a passed array of rates.

Parameters

$price
float
Price
$rates
array
Taxation Rate

Returns

array
public
# round( mixed $in )

Round to precision.

Round to precision.

Filter example: to return rounding to .5 cents you'd use:

public function euro_5cent_rounding( $in ) { return round( $in / 5, 2 ) * 5; } add_filter( 'woocommerce_tax_round', 'euro_5cent_rounding' );

public array
# find_rates( array $args = array() )

Searches for all matching country/state/postcode tax rates.

Searches for all matching country/state/postcode tax rates.

Parameters

$args
array
$args

Returns

array
public array
# get_rates( string $tax_class = '' )

Get's an array of matching rates for a tax class.

Get's an array of matching rates for a tax class.

Parameters

$tax_class
string
$tax_class

Returns

array
public array
# get_shop_base_rate( string $tax_class = '' )

Get's an array of matching rates for the shop's base country.

Get's an array of matching rates for the shop's base country.

Parameters

$tax_class
string
Tax Class

Returns

array
public mixed
# get_shipping_tax_rates( string $tax_class = null )

Gets an array of matching shipping tax rates for a given class.

Gets an array of matching shipping tax rates for a given class.

Parameters

$tax_class
string
Tax Class

Returns

mixed
public boolean
# is_compound( integer $key )

Return true/false depending on if a rate is a compound rate.

Return true/false depending on if a rate is a compound rate.

Parameters

$key
integer
key

Returns

boolean
public string
# get_rate_label( integer $key )

Return a given rates label.

Return a given rates label.

Parameters

$key
integer
key

Returns

string
public string
# get_rate_code( mixed $key )

Get a rates code. Code is made up of COUNTRY-STATE-NAME-Priority. E.g GB-VAT-1, US-AL-TAX-1

Get a rates code. Code is made up of COUNTRY-STATE-NAME-Priority. E.g GB-VAT-1, US-AL-TAX-1

Parameters

$key
mixed
$key

Returns

string
public float
# get_tax_total( array $taxes )

Round tax lines and return the sum.

Round tax lines and return the sum.

Parameters

$taxes
array

Returns

float

Magic methods summary

Properties summary

public array $matched_rates
#
public array $log
#
WooCommerce API documentation generated by ApiGen 2.8.0