src/WooCommerce/Helpers/Token.php
protected function getDataValue(array $data, $property)
    {
        $value = null;
        if (array_key_exists($property, $data)) {
            // Found: return the value.
            $value = $data[$property];
        } else {
            // Not found: check in meta data or descend recursively.
            if (isset($data['meta_data'])) {
                $value = $this->getMetaDataValue($data['meta_data'], $property);
            }
            if ($value === null) {
                // Not found in meta_data: check if we should descend a level.
                $propertyParts = explode('_', $property, 2);
                if (count($propertyParts) === 2 && array_key_exists($propertyParts[0], $data) && is_array($data[$propertyParts[0]])) {
                    $value = $this->getDataValue($data[$propertyParts[0]], $propertyParts[1]);
                }
            }
        }
        return $value;
    }
protected function getDataValue(array $data, $property)
    {
        $value = null;
        if (array_key_exists($property, $data)) {
            // Found: return the value.
            $value = $data[$property];
        } else {
            // Not found: check in meta data or descend recursively.
            if (isset($data['meta_data'])) {
                $value = $this->getMetaDataValue($data['meta_data'], $property);
            }
            if ($value === null) {
                // Not found in meta_data: check if we should descend a level.
                $propertyParts = explode('_', $property, 2);
                if (count($propertyParts) === 2 && array_key_exists($propertyParts[0], $data) && is_array($data[$propertyParts[0]])) {
                    $value = $this->getDataValue($data[$propertyParts[0]], $propertyParts[1]);
                }
            }
        }
        return $value;
    }
protected function getDataValue ( array $ data , $ property ) { $ value = null ; if ( array_key_exists ( $ property , $ data ) ) { // Found: return the value. $ value = $ data [ $ property ] ; } else { // Not found: check in meta data or descend recursively. if ( isset ( $ data [ 'meta_data' ] ) ) { $ value = $ this -> getMetaDataValue ( $ data [ 'meta_data' ] , $ property ) ; } if ( $ value === null ) { // Not found in meta_data: check if we should descend a level. $ propertyParts = explode ( '_' , $ property , 2 ) ; if ( count ( $ propertyParts ) === 2 && array_key_exists ( $ propertyParts [ 0 ] , $ data ) && is_array ( $ data [ $ propertyParts [ 0 ] ] ) ) { $ value = $ this -> getDataValue ( $ data [ $ propertyParts [ 0 ] ] , $ propertyParts [ 1 ] ) ; } } } return $ value ; }
Extracts a value from a WooCommerce data object data array.

A WooCommerce data array (array with key value pairs returned from the
WC_Data::get_data() method may contain recursive data sets, e.g.
'billing' for the billing address, and a separate meta_data set.

This method recursively searches for the property by stripping it into
separate pieces delimited by underscores. E.g. billing_email may be found
in $data['billing']['email'].

@param array $data
The key value data set to search in.
@param string $property
The name of the property to search for.

@return null|string
The value for the property of the given name, or null or the empty
string if not available (or the property really equals null or the
empty string). The return value may be a scalar (numeric type) that can
be converted to a string.
Extracts a value from a WooCommerce data object data array .