diff --git a/app/code/Magento/InventoryInStorePickup/Model/IsOrderReadyForPickup.php b/app/code/Magento/InventoryInStorePickup/Model/IsOrderReadyForPickup.php index bb9db5b58f89..e2b3dca15fa3 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/IsOrderReadyForPickup.php +++ b/app/code/Magento/InventoryInStorePickup/Model/IsOrderReadyForPickup.php @@ -9,6 +9,7 @@ use Magento\InventoryInStorePickup\Model\Order\IsFulfilled; use Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface; +use Magento\Sales\Api\OrderRepositoryInterface; class IsOrderReadyForPickup implements IsOrderReadyForPickupInterface { @@ -17,15 +18,23 @@ class IsOrderReadyForPickup implements IsOrderReadyForPickupInterface */ private $isFulfilled; + /** + * @var \Magento\Sales\Api\OrderRepositoryInterface + */ + private $orderRepository; + /** * IsReadyForPickup constructor. * * @param \Magento\InventoryInStorePickup\Model\Order\IsFulfilled $isFulfilled + * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository */ public function __construct( - IsFulfilled $isFulfilled + IsFulfilled $isFulfilled, + OrderRepositoryInterface $orderRepository ) { $this->isFulfilled = $isFulfilled; + $this->orderRepository = $orderRepository; } /** @@ -35,7 +44,21 @@ public function __construct( */ public function execute(int $orderId):bool { - /*TODO: add $order->canShip() check */ - return $this->isFulfilled->execute($orderId); + return $this->canShip($orderId) && $this->isFulfilled->execute($orderId); + } + + /** + * @param int $orderId + * + * @return bool + */ + private function canShip(int $orderId):bool + { + $order = $this->orderRepository->get($orderId); + if ($order instanceof \Magento\Sales\Model\Order) { + return $order->canShip(); + } + + return true; } } diff --git a/app/code/Magento/InventoryInStorePickup/Model/NotifyOrderIsReadyAndShip.php b/app/code/Magento/InventoryInStorePickup/Model/NotifyOrderIsReadyAndShip.php index 8857f1484f84..c065ee5ba523 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/NotifyOrderIsReadyAndShip.php +++ b/app/code/Magento/InventoryInStorePickup/Model/NotifyOrderIsReadyAndShip.php @@ -47,6 +47,7 @@ public function execute(int $orderId):int } /* TODO: send email */ + /* TODO: add order comment? */ return $this->shipOrder->execute($orderId); }