docs/api/source-catalog.controller.api.localisation.currency.html
| 1: | <?php | | 2: | namespace Opencart\Catalog\Controller\Api\Localisation; | | 3: | /** | | 4: | * Class Currency | | 5: | * | | 6: | * @package Opencart\Catalog\Controller\Api\Localisation | | 7: | */ | | 8: | class Currency extends \Opencart\System\Engine\Controller { | | 9: | /** | | 10: | * @return void | | 11: | */ | | 12: | public function index(): void { | | 13: | $this->load->language('api/localisation/currency'); | | 14: | | | 15: | $json = []; | | 16: | | | 17: | if (isset($this->request->post['currency'])) { | | 18: | $currency = (string)$this->request->post['currency']; | | 19: | } else { | | 20: | $currency = ''; | | 21: | } | | 22: | | | 23: | $this->load->model('localisation/currency'); | | 24: | | | 25: | $currency_info = $this->model_localisation_currency->getCurrencyByCode($currency); | | 26: | | | 27: | if (!$currency_info) { | | 28: | $json['error'] = $this->language->get('error_currency'); | | 29: | } | | 30: | | | 31: | if (!$json) { | | 32: | $this->session->data['currency'] = $currency; | | 33: | | | 34: | $json['success'] = $this->language->get('text_success'); | | 35: | } | | 36: | | | 37: | $this->response->addHeader('Content-Type: application/json'); | | 38: | $this->response->setOutput(json_encode($json)); | | 39: | } | | 40: | } | | 41: | |
OpenCart API API documentation generated by ApiGen dev-master