Skip to content

Commit

Permalink
Fix the issue with "Shipping address is not set" exception #16555
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro-ch committed Jul 13, 2018
1 parent ce5eacd commit ab1324e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Multishipping/Controller/Checkout.php
Expand Up @@ -84,6 +84,7 @@ protected function _getCheckoutSession()
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
* @throws \Magento\Framework\Exception\NotFoundException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
Expand Down
4 changes: 1 addition & 3 deletions app/code/Magento/Quote/Model/ShippingMethodManagement.php
Expand Up @@ -171,9 +171,7 @@ public function set($cartId, $carrierCode, $methodCode)
* @param string $methodCode The shipping method code.
* @return void
* @throws InputException The shipping method is not valid for an empty cart.
* @throws CouldNotSaveException The shipping method could not be saved.
* @throws NoSuchEntityException CThe Cart includes virtual product(s) only, so a shipping address is not used.
* @throws StateException The billing or shipping address is missing. Set the address and try again.
*/
public function apply($cartId, $carrierCode, $methodCode)
{
Expand All @@ -191,7 +189,7 @@ public function apply($cartId, $carrierCode, $methodCode)
}
$shippingAddress = $quote->getShippingAddress();
if (!$shippingAddress->getCountryId()) {
throw new StateException(__('The shipping address is missing. Set the address and try again.'));
return;
}
$shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode);
}
Expand Down
Expand Up @@ -344,10 +344,6 @@ public function testSetMethodWithVirtualProduct()
$this->model->set($cartId, $carrierCode, $methodCode);
}

/**
* @expectedException \Magento\Framework\Exception\StateException
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
*/
public function testSetMethodWithoutShippingAddress()
{
$cartId = 12;
Expand All @@ -361,6 +357,7 @@ public function testSetMethodWithoutShippingAddress()
$this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false));
$this->quote->expects($this->once())
->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
$this->quote->expects($this->once())->method('collectTotals')->willReturnSelf();
$this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(null));

$this->model->set($cartId, $carrierCode, $methodCode);
Expand Down Expand Up @@ -402,10 +399,6 @@ public function testSetMethodWithCouldNotSaveException()
$this->model->set($cartId, $carrierCode, $methodCode);
}

/**
* @expectedException \Magento\Framework\Exception\StateException
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
*/
public function testSetMethodWithoutAddress()
{
$cartId = 12;
Expand All @@ -420,6 +413,7 @@ public function testSetMethodWithoutAddress()
$this->quote->expects($this->once())
->method('getShippingAddress')
->willReturn($this->shippingAddress);
$this->quote->expects($this->once())->method('collectTotals')->willReturnSelf();
$this->shippingAddress->expects($this->once())->method('getCountryId');

$this->model->set($cartId, $carrierCode, $methodCode);
Expand Down

0 comments on commit ab1324e

Please sign in to comment.