WordPress at Your Fingertips
function is not described

WC_Data::set_meta_data() public WC 2.6.0

Set all meta data from array.

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

No Hooks.

Return

null. Nothing.

Usage

$WC_Data = new WC_Data();
$WC_Data->set_meta_data( $data );
$data(array) (required)
Key/Value pairs.

Changelog

Since 2.6.0 Introduced.

Code of WC_Data::set_meta_data() WC 5.8.0

public function set_meta_data( $data ) {
	if ( ! empty( $data ) && is_array( $data ) ) {
		$this->maybe_read_meta_data();
		foreach ( $data as $meta ) {
			$meta = (array) $meta;
			if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
				$this->meta_data[] = new WC_Meta_Data(
					array(
						'id'    => $meta['id'],
						'key'   => $meta['key'],
						'value' => $meta['value'],
					)
				);
			}
		}
	}
}