Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] ISSUE-5021 fixed guest checkout with custom shipping carrier with underscores #21340

Merged
merged 2 commits into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Magento\Quote\Model\Quote;

/**
* Guest payment information management model.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GuestPaymentInformationManagement implements \Magento\Checkout\Api\GuestPaymentInformationManagementInterface
Expand Down Expand Up @@ -65,7 +67,7 @@ class GuestPaymentInformationManagement implements \Magento\Checkout\Api\GuestPa
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $paymentInformationManagement
* @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
* @param CartRepositoryInterface $cartRepository
* @param ResourceConnection|null
* @param ResourceConnection $connectionPool
* @codeCoverageIgnore
*/
public function __construct(
Expand All @@ -87,7 +89,7 @@ public function __construct(
}

/**
* {@inheritDoc}
* @inheritdoc
*/
public function savePaymentInformationAndPlaceOrder(
$cartId,
Expand Down Expand Up @@ -128,7 +130,7 @@ public function savePaymentInformationAndPlaceOrder(
}

/**
* {@inheritDoc}
* @inheritdoc
*/
public function savePaymentInformation(
$cartId,
Expand All @@ -155,7 +157,7 @@ public function savePaymentInformation(
}

/**
* {@inheritDoc}
* @inheritdoc
*/
public function getPaymentInformation($cartId)
{
Expand Down Expand Up @@ -189,9 +191,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