WC_Cart::get_cart_item_tax_classes_for_shipping()publicWC 1.0

Get all tax classes for shipping based on the items in the cart.

Method of the class: WC_Cart{}

No Hooks.

Return

Array.

Usage

$WC_Cart = new WC_Cart();
$WC_Cart->get_cart_item_tax_classes_for_shipping();

WC_Cart::get_cart_item_tax_classes_for_shipping() code WC 8.9.0

public function get_cart_item_tax_classes_for_shipping() {
	$found_tax_classes = array();

	foreach ( $this->get_cart() as $item ) {
		if ( $item['data'] && ( $item['data']->is_shipping_taxable() ) ) {
			$found_tax_classes[] = $item['data']->get_tax_class();
		}
	}

	return array_unique( $found_tax_classes );
}