13 private $cartRepository;
18 private $checkoutSession;
23 private $addressRepository;
31 \
Magento\Quote\Api\CartRepositoryInterface $cartRepository,
32 \
Magento\Checkout\Model\Session $checkoutSession,
33 \
Magento\Customer\Api\AddressRepositoryInterface $addressRepository
36 $this->checkoutSession = $checkoutSession;
46 public function beforeDispatch(
47 \
Magento\Checkout\Controller\Cart $subject,
51 $quote = $this->checkoutSession->getQuote();
54 if (
$quote->isMultipleShippingAddresses()) {
60 $defaultShipping =
$quote->getCustomer()->getDefaultShipping();
61 if ($defaultShipping) {
62 $defaultCustomerAddress = $this->addressRepository->getById(
67 $this->cartRepository->save(
$quote);
__construct(\Magento\Quote\Api\CartRepositoryInterface $cartRepository, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository)