From 32696747da5818cd022398320a05421f6b5fad0e Mon Sep 17 00:00:00 2001 From: Maksym Novik Date: Mon, 1 Apr 2019 23:22:04 +0300 Subject: [PATCH] Add "Ready for Pickup" button on the Order page in Admin Panel which notifies Customer that Order could be picked up #2034. Do not show button is order is not placed using storepickup or it can not be shipped --- .../Adminhtml/Order/View/ReadyForPickup.php | 19 ++++++++-------- .../Model/IsDisplayReadyForPickupButton.php | 22 +++++++++++++++++++ 2 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 app/code/Magento/InventoryInStorePickupAdminUi/Model/IsDisplayReadyForPickupButton.php diff --git a/app/code/Magento/InventoryInStorePickupAdminUi/Block/Adminhtml/Order/View/ReadyForPickup.php b/app/code/Magento/InventoryInStorePickupAdminUi/Block/Adminhtml/Order/View/ReadyForPickup.php index 54b508a21fbb..d908535f09ea 100644 --- a/app/code/Magento/InventoryInStorePickupAdminUi/Block/Adminhtml/Order/View/ReadyForPickup.php +++ b/app/code/Magento/InventoryInStorePickupAdminUi/Block/Adminhtml/Order/View/ReadyForPickup.php @@ -30,26 +30,26 @@ class ReadyForPickup extends \Magento\Backend\Block\Widget\Form\Container private $viewBlock; /** - * @var \Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface + * @var \Magento\InventoryInStorePickupAdminUi\Model\IsDisplayReadyForPickupButton */ - private $isReadyForPickup; + private $isDisplayButton; /** * ReadyForPickup constructor. * - * @param \Magento\Backend\Block\Widget\Context $context - * @param \Magento\Sales\Block\Adminhtml\Order\View $viewBlock - * @param \Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface $isReadyForPickup - * @param array $data + * @param \Magento\Backend\Block\Widget\Context $context + * @param \Magento\Sales\Block\Adminhtml\Order\View $viewBlock + * @param \Magento\InventoryInStorePickupAdminUi\Model\IsDisplayReadyForPickupButton $isDisplayButton + * @param array $data */ public function __construct( \Magento\Backend\Block\Widget\Context $context, \Magento\Sales\Block\Adminhtml\Order\View $viewBlock, - IsOrderReadyForPickupInterface $isReadyForPickup, + \Magento\InventoryInStorePickupAdminUi\Model\IsDisplayReadyForPickupButton $isDisplayButton, array $data = [] ) { $this->viewBlock = $viewBlock; - $this->isReadyForPickup = $isReadyForPickup; + $this->isDisplayButton = $isDisplayButton; parent::__construct($context, $data); } @@ -63,7 +63,6 @@ protected function _construct() $this->_controller = 'adminhtml_order'; $this->_mode = 'view'; - /* TODO: always display but throw warnings? */ if ($this->isDisplayButton()) { $message = __( 'Are you sure you want to notify the customer that order is ready for pickup and create shipment?' @@ -97,6 +96,6 @@ private function isEmailsSendingAllowed():bool private function isDisplayButton():bool { return $this->isEmailsSendingAllowed() - && $this->isReadyForPickup->execute((int)$this->viewBlock->getOrderId()); + && $this->isDisplayButton->execute($this->viewBlock->getOrder()); } } diff --git a/app/code/Magento/InventoryInStorePickupAdminUi/Model/IsDisplayReadyForPickupButton.php b/app/code/Magento/InventoryInStorePickupAdminUi/Model/IsDisplayReadyForPickupButton.php new file mode 100644 index 000000000000..7eacc05ba2fb --- /dev/null +++ b/app/code/Magento/InventoryInStorePickupAdminUi/Model/IsDisplayReadyForPickupButton.php @@ -0,0 +1,22 @@ +getExtensionAttributes()->getPickupLocationCode() + && $order->canShip(); + } +}