getScript($code, 4, $this->parameters->getCheckoutRetagParams()); } /** * Возвращает скрипт ретага корзины по коду. * * @param mixed $code */ public function getCartRetag($code): string { return $this->getScript($code, 3, $this->parameters->getCartRetagParams()); } /** * Возвращает скрипт ретага страницы товара по коду. * * @param mixed $code */ public function getProductRetag($code): string { return $this->getScript($code, 2, $this->parameters->getProductRetagParams()); } /** * Возвращает скрипт ретага страницы категории по коду. * * @param mixed $code */ public function getCategoryRetag($code): string { return $this->getScript($code, 1, $this->parameters->getCategoryRetagParams()); } /** * Возвращает скрипт ретага главной страницы по коду. * * @param mixed $code */ public function getMainRetag($code): string { return $this->getScript($code, 0); } protected function getScript(string $code, int $level, array $params = []): string { $vars = ''; foreach ($params as $key => $value) { $vars .= 'window.' . $key . ' = ' . json_encode($value, JSON_UNESCAPED_UNICODE) . ';' . PHP_EOL; } return ' '; } }