Skip to content

Commit d632bc8

Browse files
committed
ACP2E-1117: CustomerAddressId not set for new billing address
1 parent 77e7161 commit d632bc8

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Customer\Api\AddressRepositoryInterface;
1111
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\Serialize\SerializerInterface;
1213
use Magento\Quote\Api\CartRepositoryInterface;
1314
use Magento\Quote\Api\Data\AddressInterface;
1415
use Magento\Quote\Api\Data\PaymentInterface;
@@ -32,21 +33,29 @@ class AddressMapper implements AddressMapperInterface
3233
*/
3334
private $quoteIdMaskFactory;
3435

36+
/**
37+
* @var SerializerInterface
38+
*/
39+
private $serializer;
40+
3541
/**
3642
* AddressMapper constructor
3743
*
3844
* @param CartRepositoryInterface $cartRepository
3945
* @param AddressRepositoryInterface $addressRepository
4046
* @param QuoteIdMaskFactory $quoteIdMaskFactory
47+
* @param SerializerInterface $serializer
4148
*/
4249
public function __construct(
4350
CartRepositoryInterface $cartRepository,
4451
AddressRepositoryInterface $addressRepository,
45-
QuoteIdMaskFactory $quoteIdMaskFactory
52+
QuoteIdMaskFactory $quoteIdMaskFactory,
53+
SerializerInterface $serializer
4654
) {
4755
$this->cartRepository = $cartRepository;
4856
$this->addressRepository = $addressRepository;
4957
$this->quoteIdMaskFactory = $quoteIdMaskFactory;
58+
$this->serializer = $serializer;
5059
}
5160

5261
/**
@@ -183,8 +192,20 @@ private function checkIfShippingAddressMatchesWithBillingAddress(
183192
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
184193
$removeKeys = ['region_code', 'save_in_address_book'];
185194
$billingData = array_diff_key($billingData, array_flip($removeKeys));
186-
$difference = array_diff($billingData, $shippingData);
187-
$sameAsBillingFlag = empty($difference);
195+
$diff = array_udiff(
196+
$billingData,
197+
$shippingData,
198+
function ($el1, $el2) {
199+
if (is_object($el1)) {
200+
$el1 = $this->serializer->serialize($el1);
201+
}
202+
if (is_object($el2)) {
203+
$el2 = $this->serializer->serialize($el2);
204+
}
205+
return strcmp((string)$el1, (string)$el2);
206+
}
207+
);
208+
$sameAsBillingFlag = empty($diff);
188209
} else {
189210
$sameAsBillingFlag = false;
190211
}

0 commit comments

Comments
 (0)