* @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; } } }