currency.php (922B)
1 <?php 2 class ControllerApiCurrency extends Controller { 3 public function index() { 4 $this->load->language('api/currency'); 5 6 $json = array(); 7 8 if (!isset($this->session->data['api_id'])) { 9 $json['error'] = $this->language->get('error_permission'); 10 } else { 11 $this->load->model('localisation/currency'); 12 13 $currency_info = $this->model_localisation_currency->getCurrencyByCode($this->request->post['currency']); 14 15 if ($currency_info) { 16 $this->session->data['currency'] = $this->request->post['currency']; 17 18 unset($this->session->data['shipping_method']); 19 unset($this->session->data['shipping_methods']); 20 21 $json['success'] = $this->language->get('text_success'); 22 } else { 23 $json['error'] = $this->language->get('error_currency'); 24 } 25 } 26 27 $this->response->addHeader('Content-Type: application/json'); 28 $this->response->setOutput(json_encode($json)); 29 } 30 }