Skip to content

Commit 5c7ee91

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-42280' into 2.4-develop-pr60
2 parents efd2f66 + 9bc1d83 commit 5c7ee91

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

app/code/Magento/Sales/Helper/Guest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,20 @@ private function compareStoredBillingDataWithInput(Order $order, array $postData
276276
$lastName = $postData['oar_billing_lastname'];
277277
$zip = $postData['oar_zip'];
278278
$billingAddress = $order->getBillingAddress();
279-
return strtolower($lastName) === strtolower($billingAddress->getLastname()) &&
280-
($type === 'email' && strtolower($email) === strtolower($billingAddress->getEmail()) ||
281-
$type === 'zip' && strtolower($zip) === strtolower($billingAddress->getPostcode()));
279+
return $this->normalizeStr($lastName) === $this->normalizeStr($billingAddress->getLastname()) &&
280+
($type === 'email' && $this->normalizeStr($email) === $this->normalizeStr($billingAddress->getEmail()) ||
281+
$type === 'zip' && $this->normalizeStr($zip) === $this->normalizeStr($billingAddress->getPostcode()));
282+
}
283+
284+
/**
285+
* Trim and convert to lower case
286+
*
287+
* @param string $str
288+
* @return string
289+
*/
290+
private function normalizeStr(string $str): string
291+
{
292+
return trim(strtolower($str));
282293
}
283294

284295
/**

app/code/Magento/Sales/Test/Unit/Helper/GuestTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ public function testLoadValidOrderNotEmptyPost($post)
183183
['getLastname', 'getEmail', 'getPostcode']
184184
);
185185
$billingAddressMock->expects($this->once())->method('getLastname')
186-
->willReturn(trim($post['oar_billing_lastname']));
187-
$billingAddressMock->expects($this->any())->method('getEmail')->willReturn(trim($post['oar_email']));
188-
$billingAddressMock->expects($this->any())->method('getPostcode')->willReturn(trim($post['oar_zip']));
186+
->willReturn($post['oar_billing_lastname']);
187+
$billingAddressMock->expects($this->any())->method('getEmail')->willReturn($post['oar_email']);
188+
$billingAddressMock->expects($this->any())->method('getPostcode')->willReturn($post['oar_zip']);
189189
$this->salesOrderMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock);
190190
$this->salesOrderMock->expects($this->once())->method('getProtectCode')->willReturn($protectedCode);
191191
$metaDataMock = $this->createMock(PublicCookieMetadata::class);

0 commit comments

Comments
 (0)