Skip to content

Commit d692049

Browse files
committed
BUG#AC-3031: Customer group is NULL for guest orders - issue fixed
1 parent 65a1198 commit d692049

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,9 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
424424
}
425425
}
426426
$quote->setCustomerIsGuest(true);
427-
$groupId = $customer ? $customer->getGroupId() : GroupInterface::NOT_LOGGED_IN_ID;
428-
$quote->setCustomerGroupId($groupId);
427+
$quote->setCustomerGroupId(
428+
$quote->getCustomerId() ? $customer->getGroupId() : GroupInterface::NOT_LOGGED_IN_ID
429+
);
429430
}
430431

431432
$remoteAddress = $this->remoteAddress->getRemoteAddress();

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,16 @@ protected function setUp(): void
240240
);
241241

242242
$this->quoteMock = $this->getMockBuilder(Quote::class)
243-
->addMethods(['setCustomerEmail', 'setCustomerGroupId', 'setCustomerId', 'setRemoteIp', 'setXForwardedFor'])
243+
->addMethods(
244+
[
245+
'setCustomerEmail',
246+
'setCustomerGroupId',
247+
'setCustomerId',
248+
'getCustomerId',
249+
'setRemoteIp',
250+
'setXForwardedFor',
251+
]
252+
)
244253
->onlyMethods(
245254
[
246255
'assignCustomer',
@@ -853,6 +862,7 @@ public function testPlaceOrderIfCustomerIsGuest(): void
853862
$this->quoteMock->expects($this->any())->method('getBillingAddress')->with()->willReturn($addressMock);
854863

855864
$this->quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(true)->willReturnSelf();
865+
$this->quoteMock->expects($this->once())->method('getCustomerId')->willReturn(null);
856866
$this->quoteMock->expects($this->once())
857867
->method('setCustomerGroupId')
858868
->with(GroupInterface::NOT_LOGGED_IN_ID);

0 commit comments

Comments
 (0)