WC_Data::get_meta PHP Method

get_meta() public method

Get Meta Data by Key.
Since: 2.6.0
public get_meta ( string $key = '', boolean $single = true, string $context = 'view' ) : mixed
$key string
$single boolean return first found meta with key, or all with $key
$context string What the value is for. Valid values are view and edit.
return mixed
    public function get_meta($key = '', $single = true, $context = 'view')
    {
        $array_keys = array_keys(wp_list_pluck($this->get_meta_data(), 'key'), $key);
        $value = '';
        if (!empty($array_keys)) {
            if ($single) {
                $value = $this->meta_data[current($array_keys)]->value;
            } else {
                $value = array_intersect_key($this->meta_data, array_flip($array_keys));
            }
            if ('view' === $context) {
                $value = apply_filters($this->get_hook_prefix() . $key, $value, $this);
            }
        }
        return $value;
    }