WC_Structured_Data::set_data()publicWC 1.0

Sets data.

Method of the class: WC_Structured_Data{}

No Hooks.

Returns

true|false.

Usage

$WC_Structured_Data = new WC_Structured_Data();
$WC_Structured_Data->set_data( $data, $reset );
$data(array) (required)
Structured data.
$reset(true|false)
Unset data .
Default: false)

WC_Structured_Data::set_data() code WC 9.8.5

public function set_data( $data, $reset = false ) {
	if ( ! isset( $data['@type'] ) || ! preg_match( '|^[a-zA-Z]{1,20}$|', $data['@type'] ) ) {
		return false;
	}

	if ( $reset && isset( $this->_data ) ) {
		unset( $this->_data );
	}

	$this->_data[] = $data;

	return true;
}