WC_Data::get_prop( string $prop, string $context = 'view' )

Gets a prop for a getter method.


Description Description

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


Parameters Parameters

$prop

(Required) Name of prop to get.

$context

(Optional) What the value is for. Valid values are view and edit.

Default value: 'view'


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/abstracts/abstract-wc-data.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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