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

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
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.