12 use Psr\Log\LoggerInterface as Logger;
91 __(
'The Cart includes virtual product(s) only, so a shipping address is not used.')
95 $saveInAddressBook =
$address->getSaveInAddressBook() ? 1 : 0;
96 $sameAsBilling =
$address->getSameAsBilling() ? 1 : 0;
97 $customerAddressId =
$address->getCustomerAddressId();
98 $this->addressValidator->validate(
$address);
102 if ($customerAddressId ===
null) {
103 $address->setCustomerAddressId(
null);
106 if ($customerAddressId) {
107 $addressData = $this->addressRepository->getById($customerAddressId);
112 $address->setSameAsBilling($sameAsBilling);
113 $address->setSaveInAddressBook($saveInAddressBook);
114 $address->setCollectShippingRates(
true);
118 }
catch (\Exception $e) {
119 $this->logger->critical($e);
120 throw new InputException(
__(
'The address failed to save. Verify the address and try again.'));
122 return $quote->getShippingAddress()->getId();
132 if (
$quote->isVirtual()) {
133 throw new NoSuchEntityException(
134 __(
'The Cart includes virtual product(s) only, so a shipping address is not used.')
138 return $quote->getShippingAddress();
elseif(isset( $params[ 'redirect_parent']))
assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address)
__construct(\Magento\Quote\Api\CartRepositoryInterface $quoteRepository, QuoteAddressValidator $addressValidator, Logger $logger, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector)