WC_Product_Variation::get_tax_class( string $context = 'view' )

Returns the tax class.


Description Description

Does not use get_prop so it can handle ‘parent’ inheritance correctly.


Parameters Parameters

$context

(Optional) view, edit, or unfiltered.

Default value: 'view'


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/class-wc-product-variation.php

	public function get_tax_class( $context = 'view' ) {
		$value = null;

		if ( array_key_exists( 'tax_class', $this->data ) ) {
			$value = array_key_exists( 'tax_class', $this->changes ) ? $this->changes['tax_class'] : $this->data['tax_class'];

			if ( 'edit' !== $context && 'parent' === $value ) {
				$value = $this->parent_data['tax_class'];
			}

			if ( 'view' === $context ) {
				$value = apply_filters( $this->get_hook_prefix() . 'tax_class', $value, $this );
			}
		}
		return $value;
	}


Top ↑

User Contributed Notes User Contributed Notes

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