WC_Data::add_meta_data( string $key, string|array $value, bool $unique = false )
Add meta data.
Description Description
Parameters Parameters
- $key
-
(Required) Meta key.
- $value
-
(Required) Meta value.
- $unique
-
(Optional) Should this be a unique key?.
Default value: false
Source Source
File: includes/abstracts/abstract-wc-data.php
public function add_meta_data( $key, $value, $unique = false ) { if ( $this->is_internal_meta_key( $key ) ) { $function = 'set_' . $key; if ( is_callable( array( $this, $function ) ) ) { return $this->{$function}( $value ); } } $this->maybe_read_meta_data(); if ( $unique ) { $this->delete_meta_data( $key ); } $this->meta_data[] = new WC_Meta_Data( array( 'key' => $key, 'value' => $value, ) ); }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |