'Order #']; public function getPlaceholdersData() { if (($id = $this->getTransactionId()) !== null) { $this->setPrimaryKey($id); $this->_setHtmlPlaceholdersData($this->getData()); /** @var App_Doc_Site $doc */ $doc = Zend_Registry::get('doc'); if ($doc->isGtmEnabled()) { $this->_setGtmValues(); } } else { $url = Qs_SiteMap::findFirst(null, ['type' => 'ECommerce_Cart_'], ['type' => 'default'], 'url'); Qs_Http::redirect($url); } return parent::getPlaceholdersData(); } public function getPlaceholdersPreviewData() { $this->_setHtmlPlaceholdersData(array_fill_keys(array_keys($this->_htmlPlaceholdersFields), 'X')); return parent::getPlaceholdersData(); } protected function _setGtmValues() { $transactionData = $this->getData(); $cartObj = new App_ECommerce_Cart_Obj(); $cartObj->setPrimaryKey($cartObj->getCartIdByTransaction($transactionData['id'])); $products = $cartObj->getList(); $categories = $this->_getGtmProductCategories(Qs_Array::fetchCol($products, 'productCategoryId')); foreach ($products as &$product) { $product['productCategory'] = Qs_Array::get($categories, (string) $product['productCategoryId'], ''); } unset($product); /** @var App_Doc_Site $doc */ $doc = Zend_Registry::get('doc'); $doc->addGtmValues(Qs_Gtm::adGetPurchase($transactionData, $products)); //$doc->addGtmValues(Qs_Gtm::gaGetECommerce($transactionData, $products)); // disabled, by default using enhanced ecommerce $doc->addGtmValues(Qs_Gtm::eeGetMeasuringPurchases($transactionData, $products)); return $this; } protected function _getGtmProductCategories(array $productIds) { $categories = []; if ($productIds) { $select = $this->_db->select(); $select->from($this->_getPair('ProductCategory', 'pc'), ['id', 'title']); $select->where('`pc`.`id` IN (?)', $productIds, Qs_Db::INT_TYPE); $categories = $this->_db->fetchPairs($select); } return $categories; } }