Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates

SimpleProductTemplate::get_tax_classespublic staticWC 1.0

Get the tax classes as select options.

Method of the class: SimpleProductTemplate{}

No Hooks.

Returns

Array. Array of options.

Usage

$result = SimpleProductTemplate::get_tax_classes( $post_type );
$post_type(string)
The post type.
Default: 'product'

SimpleProductTemplate::get_tax_classes() code WC 10.3.5

public static function get_tax_classes( $post_type = 'product' ) {
	$tax_classes = array();

	if ( 'product_variation' === $post_type ) {
		$tax_classes[] = array(
			'label' => __( 'Same as main product', 'woocommerce' ),
			'value' => 'parent',
		);
	}

	// Add standard class.
	$tax_classes[] = array(
		'label' => __( 'Standard rate', 'woocommerce' ),
		'value' => '',
	);

	$classes = WC_Tax::get_tax_rate_classes();

	foreach ( $classes as $tax_class ) {
		$tax_classes[] = array(
			'label' => $tax_class->name,
			'value' => $tax_class->slug,
		);
	}

	return $tax_classes;
}