WC_Data::set_prop()protectedWC 3.0.0

Sets a prop for a setter method.

This stores changes in a special array so we can track what needs saving the the DB later.

Method of the class: WC_Data{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->set_prop( $prop, $value );
$prop(string) (required)
Name of prop to set.
$value(mixed) (required)
Value of the prop.

Changelog

Since 3.0.0 Introduced.

WC_Data::set_prop() code WC 8.7.0

protected function set_prop( $prop, $value ) {
	if ( array_key_exists( $prop, $this->data ) ) {
		if ( true === $this->object_read ) {
			if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
				$this->changes[ $prop ] = $value;
			}
		} else {
			$this->data[ $prop ] = $value;
		}
	}
}