src/OpenCart/Invoice/Creator.php
protected function isAddressInGeoZone(array $order, $addressType, $geoZoneId)
    {
        $fallbackAddressType = $addressType === 'payment' ? 'shipping' : 'payment';
        if (!empty($order["{$addressType}_country_id"])) {
            $countryId = $order["{$addressType}_country_id"];
            $zoneId = !empty($order["{$addressType}_zone_id"]) ? $order["{$addressType}_zone_id"] : 0;
        } elseif (!empty($order["{$fallbackAddressType}_country_id"])) {
            $countryId = $order["{$fallbackAddressType}_country_id"];
            $zoneId = !empty($order["{$fallbackAddressType}_zone_id"]) ? $order["{$fallbackAddressType}_zone_id"] : 0;
        } else {
            $countryId = 0;
            $zoneId = 0;
        }

        $zones = $this->getZoneToGeoZones($geoZoneId);
        foreach ($zones as $zone) {
            // Check if this zone definition covers the same country.
            if ($zone['country_id'] == $countryId) {
                // Check if the zone definition covers the whole country or if
                // they are equal.
                if ($zone['zone_id'] == 0 || $zone['zone_id'] == $zoneId) {
                    return true;
                }
            }
        }
        return false;
    }
protected function isAddressInGeoZone(array $order, $addressType, $geoZoneId)
    {
        $fallbackAddressType = $addressType === 'payment' ? 'shipping' : 'payment';
        if (!empty($order["{$addressType}_country_id"])) {
            $countryId = $order["{$addressType}_country_id"];
            $zoneId = !empty($order["{$addressType}_zone_id"]) ? $order["{$addressType}_zone_id"] : 0;
        } elseif (!empty($order["{$fallbackAddressType}_country_id"])) {
            $countryId = $order["{$fallbackAddressType}_country_id"];
            $zoneId = !empty($order["{$fallbackAddressType}_zone_id"]) ? $order["{$fallbackAddressType}_zone_id"] : 0;
        } else {
            $countryId = 0;
            $zoneId = 0;
        }

        $zones = $this->getZoneToGeoZones($geoZoneId);
        foreach ($zones as $zone) {
            // Check if this zone definition covers the same country.
            if ($zone['country_id'] == $countryId) {
                // Check if the zone definition covers the whole country or if
                // they are equal.
                if ($zone['zone_id'] == 0 || $zone['zone_id'] == $zoneId) {
                    return true;
                }
            }
        }
        return false;
    }
protected function isAddressInGeoZone ( array $ order , $ addressType , $ geoZoneId ) { $ fallbackAddressType = $ addressType === 'payment' ? 'shipping' : 'payment' ; if ( ! empty ( $ order [ "{$addressType}_country_id" ] ) ) { $ countryId = $ order [ "{$addressType}_country_id" ] ; $ zoneId = ! empty ( $ order [ "{$addressType}_zone_id" ] ) ? $ order [ "{$addressType}_zone_id" ] : 0 ; } elseif ( ! empty ( $ order [ "{$fallbackAddressType}_country_id" ] ) ) { $ countryId = $ order [ "{$fallbackAddressType}_country_id" ] ; $ zoneId = ! empty ( $ order [ "{$fallbackAddressType}_zone_id" ] ) ? $ order [ "{$fallbackAddressType}_zone_id" ] : 0 ; } else { $ countryId = 0 ; $ zoneId = 0 ; } $ zones = $ this -> getZoneToGeoZones ( $ geoZoneId ) ; foreach ( $ zones as $ zone ) { // Check if this zone definition covers the same country. if ( $ zone [ 'country_id' ] == $ countryId ) { // Check if the zone definition covers the whole country or if // they are equal. if ( $ zone [ 'zone_id' ] == 0 || $ zone [ 'zone_id' ] == $ zoneId ) { return true ; } } } return false ; }
Returns whether the address of the order lies within the geo zone.

@param array $order
The order.
@param string $addressType
'payment' or 'shipping'.
@param int $geoZoneId
The id of the geo zone.

@return bool
True if the address of the order lies within the geo zone, false
otherwise.

@throws \Exception
Returns whether the address of the order lies within the geo zone .