71 if ($this->customerSession->isLoggedIn()) {
72 $customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
73 if ($defaultShipping =
$customer->getDefaultShipping()) {
74 $address = $this->addressRepository->getById($defaultShipping);
77 $estimatedAddress = $this->estimatedAddressFactory->create();
78 $estimatedAddress->setCountryId(
$address->getCountryId());
79 $estimatedAddress->setPostcode(
$address->getPostcode());
80 $estimatedAddress->setRegion((
string)
$address->getRegion()->getRegion());
81 $estimatedAddress->setRegionId(
$address->getRegionId());
82 $this->shippingMethodManager->estimateByAddress(
$quote->getId(), $estimatedAddress);
83 $this->quoteRepository->save(
$quote);
__construct(\Magento\Customer\Model\Session $customerSession, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory $estimatedAddressFactory, \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManager, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository)