/** * Check Country targeting option * * @param string $filter include => client country should exists in given country ids * exclude => client country should not exists in given country ids * @param array $countryIds Country ids to match * * @return boolean True when targeting country option matching to client country * False otherwise */ public function checkTargetingCountry($filter, $countryIds) { // getClient country using GeoIp component $geoIpComponentController = $this->getGeoIpComponent(); if (!$geoIpComponentController) { return false; } $clientRecord = $geoIpComponentController->getClientRecord(); if (!$clientRecord) { return false; } $clientCountryAlpha2 = $clientRecord->country->isoCode; $clientCountryId = \Cx\Core\Country\Controller\Country::getIdByAlpha2($clientCountryAlpha2); $isCountryExists = in_array($clientCountryId, $countryIds); if ($filter == 'include') { return $isCountryExists; } else { return !$isCountryExists; } }