Skip to content

Commit ab1324e

Browse files
committed
Fix the issue with "Shipping address is not set" exception #16555
1 parent ce5eacd commit ab1324e

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

app/code/Magento/Multishipping/Controller/Checkout.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected function _getCheckoutSession()
8484
*
8585
* @param RequestInterface $request
8686
* @return \Magento\Framework\App\ResponseInterface
87+
* @throws \Magento\Framework\Exception\NotFoundException
8788
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8889
* @SuppressWarnings(PHPMD.NPathComplexity)
8990
*/

app/code/Magento/Quote/Model/ShippingMethodManagement.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ public function set($cartId, $carrierCode, $methodCode)
171171
* @param string $methodCode The shipping method code.
172172
* @return void
173173
* @throws InputException The shipping method is not valid for an empty cart.
174-
* @throws CouldNotSaveException The shipping method could not be saved.
175174
* @throws NoSuchEntityException CThe Cart includes virtual product(s) only, so a shipping address is not used.
176-
* @throws StateException The billing or shipping address is missing. Set the address and try again.
177175
*/
178176
public function apply($cartId, $carrierCode, $methodCode)
179177
{
@@ -191,7 +189,7 @@ public function apply($cartId, $carrierCode, $methodCode)
191189
}
192190
$shippingAddress = $quote->getShippingAddress();
193191
if (!$shippingAddress->getCountryId()) {
194-
throw new StateException(__('The shipping address is missing. Set the address and try again.'));
192+
return;
195193
}
196194
$shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode);
197195
}

app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,6 @@ public function testSetMethodWithVirtualProduct()
344344
$this->model->set($cartId, $carrierCode, $methodCode);
345345
}
346346

347-
/**
348-
* @expectedException \Magento\Framework\Exception\StateException
349-
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
350-
*/
351347
public function testSetMethodWithoutShippingAddress()
352348
{
353349
$cartId = 12;
@@ -361,6 +357,7 @@ public function testSetMethodWithoutShippingAddress()
361357
$this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false));
362358
$this->quote->expects($this->once())
363359
->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
360+
$this->quote->expects($this->once())->method('collectTotals')->willReturnSelf();
364361
$this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(null));
365362

366363
$this->model->set($cartId, $carrierCode, $methodCode);
@@ -402,10 +399,6 @@ public function testSetMethodWithCouldNotSaveException()
402399
$this->model->set($cartId, $carrierCode, $methodCode);
403400
}
404401

405-
/**
406-
* @expectedException \Magento\Framework\Exception\StateException
407-
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
408-
*/
409402
public function testSetMethodWithoutAddress()
410403
{
411404
$cartId = 12;
@@ -420,6 +413,7 @@ public function testSetMethodWithoutAddress()
420413
$this->quote->expects($this->once())
421414
->method('getShippingAddress')
422415
->willReturn($this->shippingAddress);
416+
$this->quote->expects($this->once())->method('collectTotals')->willReturnSelf();
423417
$this->shippingAddress->expects($this->once())->method('getCountryId');
424418

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

0 commit comments

Comments
 (0)