Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/opencart/opencart/issues/12661
- Loading branch information
1 parent
8157b21
commit 41879c4
Showing
7 changed files
with
169 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace Opencart\Catalog\Controller\Api\Localisation; | ||
/** | ||
* Class Language | ||
* | ||
* @package Opencart\Catalog\Controller\Api\Localisation | ||
*/ | ||
class Language extends \Opencart\System\Engine\Controller { | ||
/** | ||
* @return void | ||
*/ | ||
public function index(): void { | ||
$this->load->language('api/localisation/language'); | ||
|
||
$json = []; | ||
|
||
if (isset($this->request->post['language'])) { | ||
$language = (string)$this->request->post['language']; | ||
} else { | ||
$language = ''; | ||
} | ||
|
||
$this->load->model('localisation/language'); | ||
|
||
$language_info = $this->model_localisation_currency->getCurrencyByCode($language); | ||
|
||
if (!$language_info) { | ||
$json['error'] = $this->language->get('error_language'); | ||
} | ||
|
||
if (!$json) { | ||
$this->session->data['language'] = $language; | ||
|
||
$json['success'] = $this->language->get('text_success'); | ||
} | ||
|
||
$this->response->addHeader('Content-Type: application/json'); | ||
$this->response->setOutput(json_encode($json)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace Opencart\Catalog\Controller\Api\Localisation; | ||
/** | ||
* Class Store | ||
* | ||
* @package Opencart\Catalog\Controller\Api\Localisation | ||
*/ | ||
class Store extends \Opencart\System\Engine\Controller { | ||
/** | ||
* @return void | ||
*/ | ||
public function index(): void { | ||
$this->load->language('api/localisation/store'); | ||
|
||
$json = []; | ||
|
||
if (isset($this->request->post['store'])) { | ||
$store = (string)$this->request->post['store']; | ||
} else { | ||
$store = ''; | ||
} | ||
|
||
$this->load->model('setting/store'); | ||
|
||
$language_info = $this->model_localisation_store->getStoreByCode($store); | ||
|
||
if (!$language_info) { | ||
$json['error'] = $this->language->get('error_store'); | ||
} | ||
|
||
if (!$json) { | ||
$this->session->data['store'] = $store; | ||
|
||
$json['success'] = $this->language->get('text_success'); | ||
} | ||
|
||
$this->response->addHeader('Content-Type: application/json'); | ||
$this->response->setOutput(json_encode($json)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
// Text | ||
$_['text_success'] = 'Success: Your language has been changed!'; | ||
|
||
// Error | ||
$_['error_currency'] = 'Warning: Language could not be found!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters