Skip to content

Commit 0c38d57

Browse files
committed
ACP2E-1117: CustomerAddressId not set for new billing address
1 parent cc84f6a commit 0c38d57

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

app/code/Magento/Checkout/Model/AddressComparator.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,25 @@
99

1010
use Magento\Quote\Api\Data\AddressInterface;
1111

12+
use Magento\Framework\Serialize\SerializerInterface;
13+
1214
class AddressComparator implements AddressComparatorInterface
1315
{
16+
/**
17+
* @var SerializerInterface
18+
*/
19+
private $serializer;
20+
21+
/**
22+
* AddressComparator constructor
23+
*
24+
* @param SerializerInterface $serializer
25+
*/
26+
public function __construct(SerializerInterface $serializer)
27+
{
28+
$this->serializer = $serializer;
29+
}
30+
1431
/**
1532
* @inheritDoc
1633
*/

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
9797
* @param AddressRepositoryInterface|null $addressRepository
9898
* @param AddressComparatorInterface|null $addressComparator
9999
* @codeCoverageIgnore
100+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
100101
*/
101102
public function __construct(
102103
\Magento\Quote\Api\BillingAddressManagementInterface $billingAddressManagement,
@@ -165,7 +166,9 @@ public function savePaymentInformationAndPlaceOrder(
165166

166167
/**
167168
* @inheritdoc
169+
*
168170
* @throws LocalizedException
171+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
169172
*/
170173
public function savePaymentInformation(
171174
$cartId,
@@ -194,15 +197,16 @@ public function savePaymentInformation(
194197
$quote->setBillingAddress($billingAddress);
195198
$quote->setDataChanges(true);
196199
$shippingAddress = $quote->getShippingAddress();
197-
$sameAsBilling = (bool)$shippingAddress->getSameAsBilling()
198-
|| $this->addressComparator->isEqual($shippingAddress, $billingAddress);
199-
if ($sameAsBilling) {
200-
$this->saveNewShippingAddress($quote);
201-
}
202-
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
203-
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
204-
if ($shippingRate) {
205-
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
200+
if ($shippingAddress) {
201+
if ((bool)$shippingAddress->getSameAsBilling()
202+
|| $this->addressComparator->isEqual($shippingAddress, $billingAddress)) {
203+
$this->saveNewShippingAddress($quote);
204+
}
205+
if ($shippingAddress->getShippingMethod()) {
206+
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
207+
if ($shippingRate) {
208+
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
209+
}
206210
}
207211
}
208212
}
@@ -241,9 +245,10 @@ private function getLogger()
241245
* Save shipping address information
242246
*
243247
* @param Quote $quote
248+
* @return void
244249
* @throws LocalizedException
245250
*/
246-
private function saveNewShippingAddress(Quote $quote)
251+
private function saveNewShippingAddress(Quote $quote): void
247252
{
248253
$quote->getShippingAddress()->setSameAsBilling(1);
249254
$shippingAddressData = $quote->getShippingAddress()->exportCustomerAddress();

0 commit comments

Comments
 (0)