Skip to content

Commit

Permalink
Add "Ready for Pickup" button on the Order page in Admin Panel which …
Browse files Browse the repository at this point in the history
…notifies Customer that Order could be picked up #2034.

Added canShip() check to IsOrderReadyForPickup;
Added TODO
  • Loading branch information
novikor committed Mar 31, 2019
1 parent 166410d commit 5fc0018
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Magento\InventoryInStorePickup\Model\Order\IsFulfilled;
use Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface;
use Magento\Sales\Api\OrderRepositoryInterface;

class IsOrderReadyForPickup implements IsOrderReadyForPickupInterface
{
Expand All @@ -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;
}

/**
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function execute(int $orderId):int
}

/* TODO: send email */
/* TODO: add order comment? */

return $this->shipOrder->execute($orderId);
}
Expand Down

0 comments on commit 5fc0018

Please sign in to comment.