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.

Метод класса: WC_Data{}

Хуки из метода

Возвращает

Разное.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_prop( $prop, $context );
$prop(строка) (обязательный)
Name of prop to get.
$context(строка)
What the value is for. Valid values are view and edit.
По умолчанию: 'view'

Список изменений

С версии 3.0.0 Введена.

Код WC_Data::get_prop() WC 8.7.0

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;
}