addressFactory = $addressFactory; $this->_isScopePrivate = true; $this->httpContext = $httpContext; $this->customerRepository = $customerRepository; $this->checkoutSession = $resourceSession; $this->customerSession = $customerSession; parent::__construct($context, $data); } /** * Initialize shipping address step * * @return void */ protected function _construct() { $this->checkoutSession->setStepData( 'shipping', ['label' => __('Shipping Information'), 'is_show' => $this->isShow()] ); parent::_construct(); } /** * Return checkout method * * @return string */ public function getMethod() { return $this->getQuote()->getCheckoutMethod(); } /** * Retrieve is allow and show block * * @return bool */ public function isShow() { return !$this->getQuote()->isVirtual(); } /** * Return Sales Quote Address model (shipping address) * * @return \Magento\Quote\Model\Quote\Address */ public function getAddress() { if ($this->address === null) { if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) { $this->address = $this->getQuote()->getShippingAddress(); } else { $this->address = $this->addressFactory->create(); } } return $this->address; } /** * Get config * * @param string $path * @return string|null */ public function getConfig($path) { return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); } /** * Get logged in customer * * @return \Magento\Customer\Api\Data\CustomerInterface */ protected function _getCustomer() { if (empty($this->customer)) { $this->customer = $this->customerRepository->getById($this->customerSession->getCustomerId()); } return $this->customer; } /** * Retrieve sales quote model * * @return Quote */ public function getQuote() { if (empty($this->quote)) { $this->quote = $this->checkoutSession->getQuote(); } return $this->quote; } /** * @return bool */ public function isCustomerLoggedIn() { return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); } }