Skip to content

Commit 06d52d7

Browse files
committed
Merge remote-tracking branch 'origin/MC-31586' into MC-32120
2 parents b37b15d + e964252 commit 06d52d7

File tree

5 files changed

+348
-147
lines changed

5 files changed

+348
-147
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/Address/SaveQuoteAddressToCustomerAddressBook.php

Lines changed: 0 additions & 104 deletions
This file was deleted.

app/code/Magento/QuoteGraphQl/Model/Cart/GetShippingAddress.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1313
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1414
use Magento\Quote\Model\Quote\Address;
15-
use Magento\QuoteGraphQl\Model\Cart\Address\SaveQuoteAddressToCustomerAddressBook;
1615

1716
/**
18-
* Get shipping address
17+
* Model for getting shipping address
1918
*/
2019
class GetShippingAddress
2120
{
@@ -24,21 +23,13 @@ class GetShippingAddress
2423
*/
2524
private $quoteAddressFactory;
2625

27-
/**
28-
* @var SaveQuoteAddressToCustomerAddressBook
29-
*/
30-
private $saveQuoteAddressToCustomerAddressBook;
31-
3226
/**
3327
* @param QuoteAddressFactory $quoteAddressFactory
34-
* @param SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook
3528
*/
3629
public function __construct(
37-
QuoteAddressFactory $quoteAddressFactory,
38-
SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook
30+
QuoteAddressFactory $quoteAddressFactory
3931
) {
4032
$this->quoteAddressFactory = $quoteAddressFactory;
41-
$this->saveQuoteAddressToCustomerAddressBook = $saveQuoteAddressToCustomerAddressBook;
4233
}
4334

4435
/**
@@ -96,25 +87,15 @@ private function createShippingAddress(
9687

9788
if (null === $customerAddressId) {
9889
$shippingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput);
99-
100-
// need to save address only for registered user and if save_in_address_book = true
101-
if (0 !== $customerId
102-
&& isset($addressInput['save_in_address_book'])
103-
&& (bool)$addressInput['save_in_address_book'] === true
104-
) {
105-
$this->saveQuoteAddressToCustomerAddressBook->execute($shippingAddress, $customerId);
106-
}
10790
} else {
10891
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
10992
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
11093
}
111-
11294
$shippingAddress = $this->quoteAddressFactory->createBasedOnCustomerAddress(
11395
(int)$customerAddressId,
11496
$customerId
11597
);
11698
}
117-
11899
return $shippingAddress;
119100
}
120101
}

app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Magento\GraphQl\Model\Query\ContextInterface;
1414
use Magento\Quote\Api\Data\CartInterface;
1515
use Magento\Quote\Model\Quote\Address;
16-
use Magento\QuoteGraphQl\Model\Cart\Address\SaveQuoteAddressToCustomerAddressBook;
1716

1817
/**
1918
* Set billing address for a specified shopping cart
@@ -30,24 +29,16 @@ class SetBillingAddressOnCart
3029
*/
3130
private $assignBillingAddressToCart;
3231

33-
/**
34-
* @var SaveQuoteAddressToCustomerAddressBook
35-
*/
36-
private $saveQuoteAddressToCustomerAddressBook;
37-
3832
/**
3933
* @param QuoteAddressFactory $quoteAddressFactory
4034
* @param AssignBillingAddressToCart $assignBillingAddressToCart
41-
* @param SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook
4235
*/
4336
public function __construct(
4437
QuoteAddressFactory $quoteAddressFactory,
45-
AssignBillingAddressToCart $assignBillingAddressToCart,
46-
SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook
38+
AssignBillingAddressToCart $assignBillingAddressToCart
4739
) {
4840
$this->quoteAddressFactory = $quoteAddressFactory;
4941
$this->assignBillingAddressToCart = $assignBillingAddressToCart;
50-
$this->saveQuoteAddressToCustomerAddressBook = $saveQuoteAddressToCustomerAddressBook;
5142
}
5243

5344
/**
@@ -113,15 +104,6 @@ private function createBillingAddress(
113104
): Address {
114105
if (null === $customerAddressId) {
115106
$billingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput);
116-
117-
$customerId = $context->getUserId();
118-
// need to save address only for registered user and if save_in_address_book = true
119-
if (0 !== $customerId
120-
&& isset($addressInput['save_in_address_book'])
121-
&& (bool)$addressInput['save_in_address_book'] === true
122-
) {
123-
$this->saveQuoteAddressToCustomerAddressBook->execute($billingAddress, $customerId);
124-
}
125107
} else {
126108
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
127109
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
@@ -133,15 +115,13 @@ private function createBillingAddress(
133115
);
134116
}
135117
$errors = $billingAddress->validate();
136-
137118
if (true !== $errors) {
138119
$e = new GraphQlInputException(__('Billing address errors'));
139120
foreach ($errors as $error) {
140121
$e->addError(new GraphQlInputException($error));
141122
}
142123
throw $e;
143124
}
144-
145125
return $billingAddress;
146126
}
147127
}

0 commit comments

Comments
 (0)