Skip to content

Commit c76e410

Browse files
authored
ENGCOM-3477: Customer related values are NULL for guests converted to customers after checkout. #19166 #19191
2 parents df17f2f + 121a9a1 commit c76e410

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/>
6464
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
6565
<see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeAdminOrderStatus"/>
66-
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Guest" stepKey="seeAdminOrderGuest"/>
66+
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.fullname}}" stepKey="seeAdminOrderGuest"/>
6767
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeAdminOrderEmail"/>
6868
<see selector="{{AdminOrderDetailsInformationSection.billingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeAdminOrderBillingAddress"/>
6969
<see selector="{{AdminOrderDetailsInformationSection.shippingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeAdminOrderShippingAddress"/>

app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<data key="firstname">John</data>
2222
<data key="lastname">Doe</data>
2323
<data key="middlename">S</data>
24+
<data key="fullname">John Doe</data>
2425
<data key="password">pwdTest123!</data>
2526
<data key="prefix">Mr</data>
2627
<data key="suffix">Sr</data>

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
/**
2626
* Class QuoteManagement
2727
*
28+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2829
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2930
* @SuppressWarnings(PHPMD.TooManyFields)
3031
*/
@@ -356,6 +357,13 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
356357
if ($quote->getCheckoutMethod() === self::METHOD_GUEST) {
357358
$quote->setCustomerId(null);
358359
$quote->setCustomerEmail($quote->getBillingAddress()->getEmail());
360+
if ($quote->getCustomerFirstname() === null && $quote->getCustomerLastname() === null) {
361+
$quote->setCustomerFirstname($quote->getBillingAddress()->getFirstname());
362+
$quote->setCustomerLastname($quote->getBillingAddress()->getLastname());
363+
if ($quote->getBillingAddress()->getMiddlename() === null) {
364+
$quote->setCustomerMiddlename($quote->getBillingAddress()->getMiddlename());
365+
}
366+
}
359367
$quote->setCustomerIsGuest(true);
360368
$quote->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
361369
}

app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ public function testPlaceOrderIfCustomerIsGuest()
645645

646646
$addressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, ['getEmail']);
647647
$addressMock->expects($this->once())->method('getEmail')->willReturn($email);
648-
$this->quoteMock->expects($this->once())->method('getBillingAddress')->with()->willReturn($addressMock);
648+
$this->quoteMock->expects($this->any())->method('getBillingAddress')->with()->willReturn($addressMock);
649649

650650
$this->quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(true)->willReturnSelf();
651651
$this->quoteMock->expects($this->once())

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ public function testSetCustomerData(): void
9898
$customer = $quote->getCustomer();
9999
$this->assertEquals($expected, $this->convertToArray($customer));
100100
$this->assertEquals('qa@example.com', $quote->getCustomerEmail());
101+
$this->assertEquals('Joe', $quote->getCustomerFirstname());
102+
$this->assertEquals('Dou', $quote->getCustomerLastname());
103+
$this->assertEquals('Ivan', $quote->getCustomerMiddlename());
101104
}
102105

103106
/**

0 commit comments

Comments
 (0)