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.

Do not show button is order is not placed using storepickup or it can not be shipped
  • Loading branch information
novikor committed Apr 1, 2019
1 parent b695a48 commit 3269674
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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?'
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\InventoryInStorePickupAdminUi\Model;

class IsDisplayReadyForPickupButton
{
/**
* @param \Magento\Sales\Model\Order $order
*
* @return bool
*/
public function execute(\Magento\Sales\Model\Order $order):bool
{
return $order->getExtensionAttributes()->getPickupLocationCode()
&& $order->canShip();
}
}

0 comments on commit 3269674

Please sign in to comment.