WC_Data::set_meta_data( array $data )

Set all meta data from array.


Description Description


Parameters Parameters

$data

(Required) Key/Value pairs.


Top ↑

Source Source

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

	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'],
						)
					);
				}
			}
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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