/** * {@inheritDoc} */ protected function _beforeToHtml() { if ($this->_customerSession->isLoggedIn()) { $customer = $this->customerRepository->getById($this->_customerSession->getCustomerId()); if ($defaultShipping = $customer->getDefaultShipping()) { $address = $this->addressRepository->getById($defaultShipping); if ($address) { /** @var \Magento\Quote\Api\Data\EstimateAddressInterface $estimatedAddress */ $estimatedAddress = $this->estimatedAddressFactory->create(); $estimatedAddress->setCountryId($address->getCountryId()); $estimatedAddress->setPostcode($address->getPostcode()); $estimatedAddress->setRegion((string) $address->getRegion()->getRegion()); $estimatedAddress->setRegionId($address->getRegionId()); $this->shippingMethodManager->estimateByAddress($this->getQuote()->getId(), $estimatedAddress); $this->quoteRepository->save($this->getQuote()); } } } return parent::_beforeToHtml(); }
/** * {@inheritDoc} */ protected function _beforeToHtml() { $this->collectQuote->collect($this->getQuote()); return parent::_beforeToHtml(); }