helper = $helper; $this->session = $session; parent::__construct($context, $data); } /** * @return bool */ public function isRoiTrackingEnabled() { return $this->helper->isRoiTrackingEnabled(); } /** * @return \Magento\Sales\Model\Order */ private function getOrder() { return $this->session->getLastRealOrder(); } /** * Get order total * @return string */ public function getTotal() { return number_format($this->getOrder()->getBaseGrandTotal(), 2, '.', ','); } /** * Get product names * @return string */ public function getProductNames() { $items = $this->getOrder()->getAllItems(); $productNames = []; foreach ($items as $item) { if ($item->getParentItemId() === null) { $productNames[] = str_replace('"', ' ', $item->getName()); } } return json_encode($productNames); } }