Skip to content

Commit

Permalink
ISSUE-5021 fixed guest checkout for custom shipping carrier with unde…
Browse files Browse the repository at this point in the history
…rscores

(cherry picked from commit 2360efd)
  • Loading branch information
vovsky authored and hostep committed Feb 19, 2019
1 parent 88ad7a6 commit 47aee60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ private function limitShippingCarrier(Quote $quote)
{
$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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
$billingAddressId = 1;
$quote = $this->createMock(Quote::class);
$quoteBillingAddress = $this->createMock(Address::class);
$shippingRate = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Rate::class, []);
$shippingRate->setCarrier('flatrate');
$quoteShippingAddress = $this->createPartialMock(
Address::class,
['setLimitCarrier', 'getShippingMethod']
['setLimitCarrier', 'getShippingMethod', 'getShippingRateByCode']
);
$this->cartRepositoryMock->method('getActive')
->with($cartId)
Expand All @@ -302,6 +304,9 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
$quote->expects($this->once())
->method('setBillingAddress')
->with($billingAddressMock);
$quoteShippingAddress->expects($this->any())
->method('getShippingRateByCode')
->willReturn($shippingRate);
$quote->expects($this->once())
->method('setDataChanges')
->willReturnSelf();
Expand Down

0 comments on commit 47aee60

Please sign in to comment.