1: <?php
2: namespace Opencart\Catalog\Controller\Localisation;
3: /**
4: * Class Country
5: *
6: * @package Opencart\Catalog\Controller\Localisation
7: */
8: class Country extends \Opencart\System\Engine\Controller {
9: /**
10: * @return void
11: */
12: public function index(): void {
13: $json = [];
14:
15: if (isset($this->request->get['country_id'])) {
16: $country_id = (int)$this->request->get['country_id'];
17: } else {
18: $country_id = 0;
19: }
20:
21: $this->load->model('localisation/country');
22:
23: $country_info = $this->model_localisation_country->getCountry($country_id);
24:
25: if ($country_info) {
26: $this->load->model('localisation/zone');
27:
28: $json = [
29: 'country_id' => $country_info['country_id'],
30: 'name' => $country_info['name'],
31: 'iso_code_2' => $country_info['iso_code_2'],
32: 'iso_code_3' => $country_info['iso_code_3'],
33: 'address_format' => $country_info['address_format'],
34: 'postcode_required' => $country_info['postcode_required'],
35: 'zone' => $this->model_localisation_zone->getZonesByCountryId($country_id),
36: 'status' => $country_info['status']
37: ];
38: }
39:
40: $this->response->addHeader('Content-Type: application/json');
41: $this->response->setOutput(json_encode($json));
42: }
43: }
44: