70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* 2022 ECSoft
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://opensource.org/licenses/afl-3.0.php
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to dev.ecsoft@gmail.com so we can send you a copy immediately.
|
|
*
|
|
* @author ECSoft <dev.ecsoft@gmail.com>
|
|
* @copyright 2022 ECSoft
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
* International Registered Trademark & Property of ECSoft
|
|
*/
|
|
class EcsGtmProAsyncModuleFrontController extends ModuleFrontController
|
|
{
|
|
protected $dataLayer;
|
|
public $module = null;
|
|
|
|
public function __construct()
|
|
{
|
|
if (Tools::usingSecureMode()) {
|
|
$this->ssl = true;
|
|
}
|
|
return parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* @see FrontController::initContent()
|
|
*/
|
|
public function initContent()
|
|
{
|
|
$action = Tools::getValue('action');
|
|
if (!empty($action)) {
|
|
switch ($action) {
|
|
case 'user':
|
|
$this->dataLayer = $this->module->dlManager->addUserInfo();
|
|
break;
|
|
case 'cart-add':
|
|
case 'cart-remove':
|
|
$this->dataLayer = $this->module->dlManager->getCartActionDataLayer(
|
|
(int) Tools::getValue('id'),
|
|
(int) Tools::getValue('id_attribute'),
|
|
$action == 'cart-remove' ? 'remove' : 'add',
|
|
(int) Tools::getValue('qty')
|
|
);
|
|
break;
|
|
case 'product-click':
|
|
$this->dataLayer = $this->module->dlManager->productClick((int) Tools::getValue('id'), (int) Tools::getValue('id_attribute'));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function display()
|
|
{
|
|
if ($this->dataLayer) {
|
|
echo $this->dataLayer->toJson();
|
|
} else {
|
|
http_response_code(400);
|
|
die;
|
|
}
|
|
}
|
|
}
|