Skip to content

Commit a84629f

Browse files
fixed wrong customer group that assign to order
1 parent 1116437 commit a84629f

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
119119

120120
$groupId = null;
121121
if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) {
122-
$groupId = $customer->getId() ? $this->groupManagement->getDefaultGroup(
123-
$storeId
124-
)->getId() : $this->groupManagement->getNotLoggedInGroup()->getId();
122+
$groupId = $customer->getId() ? $quote->getCustomerGroupId() : $this->groupManagement->getNotLoggedInGroup()->getId();
125123
} else {
126124
// Magento always has to emulate group even if customer uses default billing/shipping address
127125
$groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber(

app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,26 +243,19 @@ public function testDispatchWithDefaultCustomerGroupId()
243243
->will($this->returnValue('customerCountryCode'));
244244
$this->quoteAddressMock->expects($this->once())->method('getVatId')->will($this->returnValue(null));
245245

246-
$this->quoteMock->expects($this->once())
246+
$this->quoteMock->expects($this->exactly(2))
247247
->method('getCustomerGroupId')
248248
->will($this->returnValue('customerGroupId'));
249249
$this->customerMock->expects($this->once())->method('getId')->will($this->returnValue('1'));
250-
$this->groupManagementMock->expects($this->once())
251-
->method('getDefaultGroup')
252-
->will($this->returnValue($this->groupInterfaceMock));
253-
$this->groupInterfaceMock->expects($this->once())
254-
->method('getId')->will($this->returnValue('defaultCustomerGroupId'));
255250
/** Assertions */
256251
$this->quoteAddressMock->expects($this->once())
257252
->method('setPrevQuoteCustomerGroupId')
258253
->with('customerGroupId');
259-
$this->quoteMock->expects($this->once())->method('setCustomerGroupId')->with('defaultCustomerGroupId');
260254
$this->customerDataFactoryMock->expects($this->any())
261255
->method('create')
262256
->willReturn($this->customerMock);
263257

264258
$this->quoteMock->expects($this->once())->method('setCustomer')->with($this->customerMock);
265-
266259
/** SUT execution */
267260
$this->model->execute($this->observerMock);
268261
}

0 commit comments

Comments
 (0)