public function getTranslated(array $address, $both = false)
    {
        $default = $this->country->getDefaultFormat();
        $format = gplcart_array_merge($default, $address['country_format']);

        gplcart_array_sort($format);

        $results = array();
        foreach ($format as $key => $data) {

            if (!array_key_exists($key, $address) || empty($data['status'])) {
                continue;
            }

            if ($key === 'country') {
                $address[$key] = $address['country_native_name'];
            }

            if ($key === 'state_id') {
                $address[$key] = $address['state_name'];
            }

            if ($key === 'city_id' && !empty($address['city_name'])) {
                $address[$key] = $address['city_name'];
            }

            if ($both) {
                $results[$data['name']] = $address[$key];
                continue;
            }

            $results[$key] = $address[$key];
        }

        return array_filter($results);
    }
public function getTranslated(array $address, $both = false)
    {
        $default = $this->country->getDefaultFormat();
        $format = gplcart_array_merge($default, $address['country_format']);

        gplcart_array_sort($format);

        $results = array();
        foreach ($format as $key => $data) {

            if (!array_key_exists($key, $address) || empty($data['status'])) {
                continue;
            }

            if ($key === 'country') {
                $address[$key] = $address['country_native_name'];
            }

            if ($key === 'state_id') {
                $address[$key] = $address['state_name'];
            }

            if ($key === 'city_id' && !empty($address['city_name'])) {
                $address[$key] = $address['city_name'];
            }

            if ($both) {
                $results[$data['name']] = $address[$key];
                continue;
            }

            $results[$key] = $address[$key];
        }

        return array_filter($results);
    }
public function getTranslated ( array $ address , $ both = false ) { $ default = $ this -> country -> getDefaultFormat ( ) ; $ format = gplcart_array_merge ( $ default , $ address [ 'country_format' ] ) ; gplcart_array_sort ( $ format ) ; $ results = array ( ) ; foreach ( $ format as $ key => $ data ) { if ( ! array_key_exists ( $ key , $ address ) || empty ( $ data [ 'status' ] ) ) { continue ; } if ( $ key === 'country' ) { $ address [ $ key ] = $ address [ 'country_native_name' ] ; } if ( $ key === 'state_id' ) { $ address [ $ key ] = $ address [ 'state_name' ] ; } if ( $ key === 'city_id' && ! empty ( $ address [ 'city_name' ] ) ) { $ address [ $ key ] = $ address [ 'city_name' ] ; } if ( $ both ) { $ results [ $ data [ 'name' ] ] = $ address [ $ key ] ; continue ; } $ results [ $ key ] = $ address [ $ key ] ; } return array_filter ( $ results ) ; }
Returns an array of translated address fields
@param array $address
@param boolean $both
@return array
Returns an array of translated address fields