Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 9688034

Browse files
author
Jakub Idziak
committed
ISSUE-5021 - fixed place order for custom shipping methods with underscore in carrier code
1 parent fb4294a commit 9688034

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
@@ -115,9 +115,8 @@ public function savePaymentInformation(
115115
$quote->setDataChanges(true);
116116
$shippingAddress = $quote->getShippingAddress();
117117
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
118-
$shippingDataArray = explode('_', $shippingAddress->getShippingMethod());
119-
$shippingCarrier = array_shift($shippingDataArray);
120-
$shippingAddress->setLimitCarrier($shippingCarrier);
118+
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
119+
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
121120
}
122121
}
123122
$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
@@ -172,9 +172,11 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
172172
$billingAddressId = 1;
173173
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
174174
$quoteBillingAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
175+
$shippingRate = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Rate::class, []);
176+
$shippingRate->setCarrier('flatrate');
175177
$quoteShippingAddress = $this->createPartialMock(
176178
\Magento\Quote\Model\Quote\Address::class,
177-
['setLimitCarrier', 'getShippingMethod']
179+
['setLimitCarrier', 'getShippingMethod', 'getShippingRateByCode']
178180
);
179181
$this->cartRepositoryMock->expects($this->any())->method('getActive')->with($cartId)->willReturn($quoteMock);
180182
$quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($quoteBillingAddress);
@@ -183,6 +185,7 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
183185
$quoteMock->expects($this->once())->method('removeAddress')->with($billingAddressId);
184186
$quoteMock->expects($this->once())->method('setBillingAddress')->with($billingAddressMock);
185187
$quoteMock->expects($this->once())->method('setDataChanges')->willReturnSelf();
188+
$quoteShippingAddress->expects($this->any())->method('getShippingRateByCode')->willReturn($shippingRate);
186189
$quoteShippingAddress->expects($this->any())->method('getShippingMethod')->willReturn('flatrate_flatrate');
187190
$quoteShippingAddress->expects($this->once())->method('setLimitCarrier')->with('flatrate')->willReturnSelf();
188191
}

0 commit comments

Comments
 (0)