customerRepository = $customerRepository; $this->_customerViewHelper = $customerViewHelper; parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** * {@inheritdoc} */ protected function _toHtml() { if ($this->_getSession()->getOrder()->getId()) { return __('Edit Order #%1', $this->_getSession()->getOrder()->getIncrementId()); } $out = $this->_getCreateOrderTitle(); return $this->escapeHtml($out); } /** * Generate title for new order creation page. * * @return string */ protected function _getCreateOrderTitle() { $customerId = $this->getCustomerId(); $storeId = $this->getStoreId(); $out = ''; if ($customerId && $storeId) { $out .= __( 'Create New Order for %1 in %2', $this->_getCustomerName($customerId), $this->getStore()->getName() ); return $out; } elseif (!$customerId && $storeId) { $out .= __('Create New Order in %1', $this->getStore()->getName()); return $out; } elseif ($customerId && !$storeId) { $out .= __('Create New Order for %1', $this->_getCustomerName($customerId)); return $out; } elseif (!$customerId && !$storeId) { $out .= __('Create New Order for New Customer'); return $out; } return $out; } /** * Get customer name by his ID * * @param int $customerId * @return string */ protected function _getCustomerName($customerId) { $customerData = $this->customerRepository->getById($customerId); return $this->_customerViewHelper->getCustomerName($customerData); } }