WC_Order_Item_Shipping::calculate_taxes
Calculate item taxes.
Метод класса: WC_Order_Item_Shipping{}
Хуки из метода
Возвращает
true|false. True if taxes were calculated.
Использование
$WC_Order_Item_Shipping = new WC_Order_Item_Shipping(); $WC_Order_Item_Shipping->calculate_taxes( $calculate_tax_for );
- $calculate_tax_for(массив)
- Location data to get taxes for. Required.
По умолчанию:array()
Список изменений
| С версии 3.2.0 | Введена. |
Код WC_Order_Item_Shipping::calculate_taxes() WC Order Item Shipping::calculate taxes WC 10.5.2
public function calculate_taxes( $calculate_tax_for = array() ) {
if ( ! isset( $calculate_tax_for['country'], $calculate_tax_for['state'], $calculate_tax_for['postcode'], $calculate_tax_for['city'], $calculate_tax_for['tax_class'] ) ) {
return false;
}
if ( wc_tax_enabled() && ProductTaxStatus::TAXABLE === $this->get_tax_status() ) {
$tax_rates = WC_Tax::find_shipping_rates( $calculate_tax_for );
$taxes = WC_Tax::calc_tax( $this->get_total(), $tax_rates, false );
$this->set_taxes( array( 'total' => $taxes ) );
} else {
$this->set_taxes( false );
}
do_action( 'woocommerce_order_item_shipping_after_calculate_taxes', $this, $calculate_tax_for );
return true;
}