WC_Data::get_prop()protectedWC 3.0.0

Gets a prop for a getter method.

Gets the value from either current pending changes, or the data itself. Context controls what happens to the value before it's returned.

{} It's a method of the class: WC_Data{}

Hooks from the method

Return

Mixed.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_prop( $prop, $context );
$prop(string) (required)
Name of prop to get.
$context(string)
What the value is for. Valid values are view and edit.
Default: 'view'

Changelog

Since 3.0.0 Introduced.

Code of WC_Data::get_prop() WC 6.8.2

protected function get_prop( $prop, $context = 'view' ) {
	$value = null;

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

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

	return $value;
}