Skip to content

Commit

Permalink
ENGCOM-3477: Customer related values are NULL for guests converted to…
Browse files Browse the repository at this point in the history
… customers after checkout. #19166 #19191

 - Merge Pull Request #19191 from Nazar65/magento2:issue-19166
 - Merged commits:
   1. ccba420
   2. f8a6d05
   3. 7607c82
   4. 560e1d7
   5. 125de74
   6. 5fb9c52
   7. e20c7ef
   8. 7d22ae8
  • Loading branch information
magento-engcom-team committed Feb 6, 2019
2 parents 8dfe26a + 7d22ae8 commit 121a9a1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeAdminOrderStatus"/>
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Guest" stepKey="seeAdminOrderGuest"/>
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.fullname}}" stepKey="seeAdminOrderGuest"/>
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeAdminOrderEmail"/>
<see selector="{{AdminOrderDetailsInformationSection.billingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeAdminOrderBillingAddress"/>
<see selector="{{AdminOrderDetailsInformationSection.shippingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeAdminOrderShippingAddress"/>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<data key="firstname">John</data>
<data key="lastname">Doe</data>
<data key="middlename">S</data>
<data key="fullname">John Doe</data>
<data key="password">pwdTest123!</data>
<data key="prefix">Mr</data>
<data key="suffix">Sr</data>
Expand Down
8 changes: 8 additions & 0 deletions app/code/Magento/Quote/Model/QuoteManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/**
* Class QuoteManagement
*
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
Expand Down Expand Up @@ -356,6 +357,13 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
if ($quote->getCheckoutMethod() === self::METHOD_GUEST) {
$quote->setCustomerId(null);
$quote->setCustomerEmail($quote->getBillingAddress()->getEmail());
if ($quote->getCustomerFirstname() === null && $quote->getCustomerLastname() === null) {
$quote->setCustomerFirstname($quote->getBillingAddress()->getFirstname());
$quote->setCustomerLastname($quote->getBillingAddress()->getLastname());
if ($quote->getBillingAddress()->getMiddlename() === null) {
$quote->setCustomerMiddlename($quote->getBillingAddress()->getMiddlename());
}
}
$quote->setCustomerIsGuest(true);
$quote->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ public function testPlaceOrderIfCustomerIsGuest()

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

$this->quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(true)->willReturnSelf();
$this->quoteMock->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public function testSetCustomerData(): void
$customer = $quote->getCustomer();
$this->assertEquals($expected, $this->convertToArray($customer));
$this->assertEquals('qa@example.com', $quote->getCustomerEmail());
$this->assertEquals('Joe', $quote->getCustomerFirstname());
$this->assertEquals('Dou', $quote->getCustomerLastname());
$this->assertEquals('Ivan', $quote->getCustomerMiddlename());
}

/**
Expand Down

0 comments on commit 121a9a1

Please sign in to comment.