Skip to content

Commit a2db268

Browse files
author
Stanislav Idolov
authored
ENGCOM-3315: [Backport] ISSUE-5021 - fixed place order for custom shipping methods with under… #18870
2 parents 0ddb881 + df0e0be commit a2db268

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ public function savePaymentInformation(
114114
$quote->setDataChanges(true);
115115
$shippingAddress = $quote->getShippingAddress();
116116
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
117-
$shippingDataArray = explode('_', $shippingAddress->getShippingMethod());
118-
$shippingCarrier = array_shift($shippingDataArray);
119-
$shippingAddress->setLimitCarrier($shippingCarrier);
117+
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
118+
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
120119
}
121120
}
122121
$this->paymentMethodManagement->set($cartId, $paymentMethod);

app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
168168
$billingAddressId = 1;
169169
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
170170
$quoteBillingAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
171+
$shippingRate = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Rate::class, []);
172+
$shippingRate->setCarrier('flatrate');
171173
$quoteShippingAddress = $this->createPartialMock(
172174
\Magento\Quote\Model\Quote\Address::class,
173-
['setLimitCarrier', 'getShippingMethod']
175+
['setLimitCarrier', 'getShippingMethod', 'getShippingRateByCode']
174176
);
175177
$this->cartRepositoryMock->expects($this->any())->method('getActive')->with($cartId)->willReturn($quoteMock);
176178
$quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($quoteBillingAddress);
@@ -179,6 +181,7 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
179181
$quoteMock->expects($this->once())->method('removeAddress')->with($billingAddressId);
180182
$quoteMock->expects($this->once())->method('setBillingAddress')->with($billingAddressMock);
181183
$quoteMock->expects($this->once())->method('setDataChanges')->willReturnSelf();
184+
$quoteShippingAddress->expects($this->any())->method('getShippingRateByCode')->willReturn($shippingRate);
182185
$quoteShippingAddress->expects($this->any())->method('getShippingMethod')->willReturn('flatrate_flatrate');
183186
$quoteShippingAddress->expects($this->once())->method('setLimitCarrier')->with('flatrate')->willReturnSelf();
184187
}

0 commit comments

Comments
 (0)