1: | <?php
|
2: | namespace Opencart\Catalog\Controller\Api\Sale;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class Affiliate extends \Opencart\System\Engine\Controller {
|
9: | |
10: | |
11: |
|
12: | public function index(): void {
|
13: | $this->load->language('api/sale/affiliate');
|
14: |
|
15: | $json = [];
|
16: |
|
17: | if (isset($this->request->post['affiliate_id'])) {
|
18: | $affiliate_id = (int)$this->request->post['affiliate_id'];
|
19: | } else {
|
20: | $affiliate_id = 0;
|
21: | }
|
22: |
|
23: | if ($affiliate_id) {
|
24: | $this->load->model('account/affiliate');
|
25: |
|
26: | $affiliate_info = $this->model_account_affiliate->getAffiliate($affiliate_id);
|
27: |
|
28: | if (!$affiliate_info) {
|
29: | $json['error'] = $this->language->get('error_affiliate');
|
30: | }
|
31: | }
|
32: |
|
33: | if (!$json) {
|
34: | if ($affiliate_id) {
|
35: | $json['success'] = $this->language->get('text_success');
|
36: |
|
37: | $this->session->data['affiliate_id'] = $affiliate_id;
|
38: | } else {
|
39: | $json['success'] = $this->language->get('text_remove');
|
40: |
|
41: | unset($this->session->data['affiliate_id']);
|
42: | }
|
43: | }
|
44: |
|
45: | $this->response->addHeader('Content-Type: application/json');
|
46: | $this->response->setOutput(json_encode($json));
|
47: | }
|
48: | }
|
49: | |