WC_Cart_Totals::get_item_tax_rates( object $item )

Get tax rates for an item. Caches rates in class to avoid multiple look ups.


Description Description


Parameters Parameters

$item

(Required) Item to get tax rates for.


Top ↑

Return Return

(array) of taxes


Top ↑

Source Source

File: includes/class-wc-cart-totals.php

	protected function get_item_tax_rates( $item ) {
		if ( ! wc_tax_enabled() ) {
			return array();
		}
		$tax_class      = $item->product->get_tax_class();
		$item_tax_rates = isset( $this->item_tax_rates[ $tax_class ] ) ? $this->item_tax_rates[ $tax_class ] : $this->item_tax_rates[ $tax_class ] = WC_Tax::get_rates( $item->product->get_tax_class(), $this->cart->get_customer() );

		// Allow plugins to filter item tax rates.
		return apply_filters( 'woocommerce_cart_totals_get_item_tax_rates', $item_tax_rates, $item, $this->cart );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.