Skip to content

Commit

Permalink
ISSUE-5021 - fixed place order for custom shipping methods with under…
Browse files Browse the repository at this point in the history
…score in carrier code
  • Loading branch information
idziakjakub committed Oct 19, 2018
1 parent fb4294a commit 9688034
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ public function savePaymentInformation(
$quote->setDataChanges(true);
$shippingAddress = $quote->getShippingAddress();
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
$shippingDataArray = explode('_', $shippingAddress->getShippingMethod());
$shippingCarrier = array_shift($shippingDataArray);
$shippingAddress->setLimitCarrier($shippingCarrier);
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
}
}
$this->paymentMethodManagement->set($cartId, $paymentMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
$billingAddressId = 1;
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
$quoteBillingAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
$shippingRate = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Rate::class, []);
$shippingRate->setCarrier('flatrate');
$quoteShippingAddress = $this->createPartialMock(
\Magento\Quote\Model\Quote\Address::class,
['setLimitCarrier', 'getShippingMethod']
['setLimitCarrier', 'getShippingMethod', 'getShippingRateByCode']
);
$this->cartRepositoryMock->expects($this->any())->method('getActive')->with($cartId)->willReturn($quoteMock);
$quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($quoteBillingAddress);
Expand All @@ -183,6 +185,7 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
$quoteMock->expects($this->once())->method('removeAddress')->with($billingAddressId);
$quoteMock->expects($this->once())->method('setBillingAddress')->with($billingAddressMock);
$quoteMock->expects($this->once())->method('setDataChanges')->willReturnSelf();
$quoteShippingAddress->expects($this->any())->method('getShippingRateByCode')->willReturn($shippingRate);
$quoteShippingAddress->expects($this->any())->method('getShippingMethod')->willReturn('flatrate_flatrate');
$quoteShippingAddress->expects($this->once())->method('setLimitCarrier')->with('flatrate')->willReturnSelf();
}
Expand Down

0 comments on commit 9688034

Please sign in to comment.