1: | <?php
2: | namespace Opencart\Catalog\Controller\Startup;
3: | /**
4: | * Class Marketing
5: | *
6: | * @package Opencart\Catalog\Controller\Startup
7: | */
8: | class Marketing extends \Opencart\System\Engine\Controller {
9: | /**
10: | * @return void
11: | */
12: | public function index(): void {
13: | $tracking = '';
14: |
15: | if (isset($this->request->get['tracking'])) {
16: | $tracking = (string)$this->request->get['tracking'];
17: | }
18: |
19: | if (isset($this->request->cookie['tracking'])) {
20: | $tracking = (string)$this->request->cookie['tracking'];
21: | }
22: |
23: | // Tracking Code
24: | if ($tracking) {
25: | $this->load->model('marketing/marketing');
26: |
27: | $marketing_info = $this->model_marketing_marketing->getMarketingByCode($tracking);
28: |
29: | if ($marketing_info) {
30: | $this->model_marketing_marketing->addReport($marketing_info['marketing_id'], $this->request->server['REMOTE_ADDR']);
31: | }
32: |
33: | if ($this->config->get('config_affiliate_status')) {
34: | $this->load->model('account/affiliate');
35: |
36: | $affiliate_info = $this->model_account_affiliate->getAffiliateByTracking($tracking);
37: |
38: | if ($affiliate_info && $affiliate_info['status']) {
39: | $this->model_account_affiliate->addReport($affiliate_info['customer_id'], $this->request->server['REMOTE_ADDR']);
40: | }
41: |
42: | if ($marketing_info || ($affiliate_info && $affiliate_info['status'])) {
43: | $this->session->data['tracking'] = $tracking;
44: |
45: | if (!isset($this->request->cookie['tracking'])) {
46: | $option = [
47: | 'expires' => $this->config->get('config_affiliate_expire') ? time() + (int)$this->config->get('config_affiliate_expire') : 0,
48: | 'path' => $this->config->get('session_path'),
49: | 'SameSite' => $this->config->get('config_session_samesite')
50: | ];
51: |
52: | setcookie('tracking', $tracking, $option);
53: | }
54: | }
55: | }
56: | }
57: | }
58: | }
59: |

OpenCart API API documentation generated by ApiGen dev-master