if (!$this->user->hasPermission('modify', 'localisation/country')) {
$this->error['warning'] = $this->language->get('error_permission');
}
$this->load->model('setting/store');
$this->load->model('sale/customer');
$this->load->model('sale/affiliate');
$this->load->model('localisation/zone');
$this->load->model('localisation/geo_zone');
foreach ($this->request->post['selected'] as $country_id) {
if ($this->config->get('config_country_id') == $country_id) {
$this->error['warning'] = $this->language->get('error_default');
}
$store_total = $this->model_setting_store->getTotalStoresByCountryId($country_id);
if ($store_total) {
$this->error['warning'] = sprintf($this->language->get('error_store'), $store_total);
}
$address_total = $this->model_sale_customer->getTotalAddressesByCountryId($country_id);
if ($address_total) {
$this->error['warning'] = sprintf($this->language->get('error_address'), $address_total);
}
$affiliate_total = $this->model_sale_affiliate->getTotalAffiliatesByCountryId($country_id);
if ($affiliate_total) {
$this->error['warning'] = sprintf($this->language->get('error_affiliate'), $affiliate_total);
}
$zone_total = $this->model_localisation_zone->getTotalZonesByCountryId($country_id);
if ($zone_total) {
$this->error['warning'] = sprintf($this->language->get('error_zone'), $zone_total);
}
$zone_to_geo_zone_total = $this->model_localisation_geo_zone->getTotalZoneToGeoZoneByCountryId($country_id);
if ($zone_to_geo_zone_total) {
$this->error['warning'] = sprintf($this->language->get('error_zone_to_geo_zone'), $zone_to_geo_zone_total);
}
}
if (!$this->error) {
return true;
} else {
return false;
}