2.0.x-2.2.x/upload/catalog/model/module/facebook_business.php [250:359]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            $this->db->query("UPDATE " . DB_PREFIX . "user_group SET permission = '" . $this->db->escape(json_encode($data)) . "' WHERE user_group_id = '" . (int)$user_group_id . "'");
        }
    }

    public function isExtensionInstalled() {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "extension WHERE `type` = 'module' AND `code` = 'facebook_business'");

        if ($query->num_rows) {
            return true;
        } else {
            return false;
        }
    }


    public function getAgentParameters() {
        $plugin_agent_name = 'exopencart';
        $opencart_version = VERSION;
        $plugin_version = $this->getPluginVersion();
    
        $agent_string = sprintf('%s-%s-%s', $plugin_agent_name, $opencart_version, $plugin_version);

        $facebook_pixel_params = array('agent' => $agent_string);

        return json_encode($facebook_pixel_params, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT);
    }

    public function getPii() {
        $facebook_pixel_pii = array();

        if ($this->config->get('facebook_pixel_use_pii')) {
            if ($this->customer->isLogged()) {
                $customer_id = $this->customer->getId();
                $email = $this->customer->getEmail();
                $firstname = $this->customer->getFirstName();
                $lastname = $this->customer->getLastName();
                $telephone = $this->customer->getTelephone();
            } elseif (isset($this->session->data['guest'])) {
                $customer_id = '';
                $email = isset($this->session->data['guest']['email']) ? $this->session->data['guest']['email'] : '';
                $firstname = isset($this->session->data['guest']['firstname']) ? $this->session->data['guest']['firstname'] : '';
                $lastname = isset($this->session->data['guest']['lastname']) ? $this->session->data['guest']['lastname'] : '';
                $telephone = isset($this->session->data['guest']['telephone']) ? $this->session->data['guest']['telephone'] : '';
            } else {
                $customer_id = '';
                $email = '';
                $firstname = '';
                $lastname = '';
                $telephone = '';
            }

            $enabled_aam_fields = explode(',', $this->config->get('facebook_pixel_enabled_aam_fields'));

            if ($enabled_aam_fields) {
                if ($email && in_array('em', $enabled_aam_fields)) {
                    $facebook_pixel_pii['em'] = htmlspecialchars($email, ENT_QUOTES, 'UTF-8');;
                }

                if ($firstname && in_array('fn', $enabled_aam_fields)) {
                    $facebook_pixel_pii['fn'] = htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8');
                }

                if ($lastname && in_array('ln', $enabled_aam_fields)) {
                    $facebook_pixel_pii['ln'] = htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8');
                }

                if ($telephone && in_array('ph', $enabled_aam_fields)) {
                    $facebook_pixel_pii['ph'] = htmlspecialchars($telephone, ENT_QUOTES, 'UTF-8');
                }

                if ($customer_id && in_array('external_id', $enabled_aam_fields)) {
                    $facebook_pixel_pii['external_id'] = (string)$customer_id;
                }
            }
        }

        return $facebook_pixel_pii;
    }

    public function getEventParameters() {
        $route = (array_key_exists('route', $this->request->get)) ? $this->request->get['route'] : null;
    
        $facebook_pixel_event_params = null;
    
        // This grabs events stored on redirects
        if (array_key_exists('facebook_pixel_event_params', $this->session->data)) {
            $facebook_pixel_event_params = $this->session->data['facebook_pixel_event_params'];
        }

        $event_name = 'ViewContent';
        $event_id = $this->generateEventId();
    
        // Checking route and handling the events fired accordingly
        switch ($route) {
            case 'checkout/success':
                $event_name = 'Purchase';

                $this->load->language('checkout/success');

                $contents = array();
                $content_ids = array();
                $value = 0;
                $num_items = 0;
                $currency = $this->session->data['currency'];

                if (isset($this->session->data['facebook_business_order_id'])) {
                    $order_id = $this->session->data['facebook_business_order_id'];
                    unset($this->session->data['facebook_business_order_id']);

                    $this->load->model('checkout/order');
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



3.0.x-and-above/upload/catalog/model/extension/module/facebook_business.php [270:378]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            $this->db->query("UPDATE " . DB_PREFIX . "user_group SET permission = '" . $this->db->escape(json_encode($data)) . "' WHERE user_group_id = '" . (int)$user_group_id . "'");
        }
    }

    public function isExtensionInstalled() {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "extension WHERE `type` = 'module' AND `code` = 'facebook_business'");

        if ($query->num_rows) {
            return true;
        } else {
            return false;
        }
    }

    public function getAgentParameters() {
        $plugin_agent_name = 'exopencart';
        $opencart_version = VERSION;
        $plugin_version = $this->getPluginVersion();
    
        $agent_string = sprintf('%s-%s-%s', $plugin_agent_name, $opencart_version, $plugin_version);

        $facebook_pixel_params = array('agent' => $agent_string);

        return json_encode($facebook_pixel_params, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT);
    }

    public function getPii() {
        $facebook_pixel_pii = array();

        if ($this->config->get('facebook_pixel_use_pii')) {
            if ($this->customer->isLogged()) {
                $customer_id = $this->customer->getId();
                $email = $this->customer->getEmail();
                $firstname = $this->customer->getFirstName();
                $lastname = $this->customer->getLastName();
                $telephone = $this->customer->getTelephone();
            } elseif (isset($this->session->data['guest'])) {
                $customer_id = '';
                $email = isset($this->session->data['guest']['email']) ? $this->session->data['guest']['email'] : '';
                $firstname = isset($this->session->data['guest']['firstname']) ? $this->session->data['guest']['firstname'] : '';
                $lastname = isset($this->session->data['guest']['lastname']) ? $this->session->data['guest']['lastname'] : '';
                $telephone = isset($this->session->data['guest']['telephone']) ? $this->session->data['guest']['telephone'] : '';
            } else {
                $customer_id = '';
                $email = '';
                $firstname = '';
                $lastname = '';
                $telephone = '';
            }

            $enabled_aam_fields = explode(',', $this->config->get('facebook_pixel_enabled_aam_fields'));

            if ($enabled_aam_fields) {
                if ($email && in_array('em', $enabled_aam_fields)) {
                    $facebook_pixel_pii['em'] = htmlspecialchars($email, ENT_QUOTES, 'UTF-8');;
                }

                if ($firstname && in_array('fn', $enabled_aam_fields)) {
                    $facebook_pixel_pii['fn'] = htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8');
                }

                if ($lastname && in_array('ln', $enabled_aam_fields)) {
                    $facebook_pixel_pii['ln'] = htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8');
                }

                if ($telephone && in_array('ph', $enabled_aam_fields)) {
                    $facebook_pixel_pii['ph'] = htmlspecialchars($telephone, ENT_QUOTES, 'UTF-8');
                }

                if ($customer_id && in_array('external_id', $enabled_aam_fields)) {
                    $facebook_pixel_pii['external_id'] = (string)$customer_id;
                }
            }
        }

        return $facebook_pixel_pii;
    }

    public function getEventParameters() {
        $route = (array_key_exists('route', $this->request->get)) ? $this->request->get['route'] : null;
    
        $facebook_pixel_event_params = null;
    
        // This grabs events stored on redirects
        if (array_key_exists('facebook_pixel_event_params', $this->session->data)) {
            $facebook_pixel_event_params = $this->session->data['facebook_pixel_event_params'];
        }

        $event_name = 'ViewContent';
        $event_id = $this->generateEventId();
    
        // Checking route and handling the events fired accordingly
        switch ($route) {
            case 'checkout/success':
                $event_name = 'Purchase';

                $this->load->language('checkout/success');

                $contents = array();
                $content_ids = array();
                $value = 0;
                $num_items = 0;
                $currency = $this->session->data['currency'];

                if (isset($this->session->data['facebook_business_order_id'])) {
                    $order_id = $this->session->data['facebook_business_order_id'];
                    unset($this->session->data['facebook_business_order_id']);

                    $this->load->model('checkout/order');
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



