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 the button itself
  • Loading branch information
novikor committed Mar 28, 2019
1 parent 92f81d4 commit 3c78648
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\InventoryInStorePickupAdminUi\Block\Adminhtml\Order\View;

/**
* TODO: is it possible to replace with UI Component?
*
* @package Magento\InventoryInStorePickupAdminUi\Block\Adminhtml\Order\View
*/
class ReadyForPickup extends \Magento\Backend\Block\Widget\Form\Container
{
const ADMIN_SALES_EMAIL_RESOURCE = 'Magento_Sales::emails';

/**
* Block group
*
* @var string
*/
protected $_blockGroup = 'Magento_Sales';

/**
* Rendering Ready for Pickup button
*/
protected function _construct()
{
$this->_objectId = 'order_id';
$this->_controller = 'adminhtml_order';
$this->_mode = 'view';

if ($this->isEmailsSendingAllowed()) {/* TODO: add is order ready check */
$message = __('Are you sure you want to notify the customer that order is ready for pickup?');
$this->addButton(
'ready_for_pickup',
[
'label' => __('Notify Order is Ready for Pickup'),
'class' => 'action-default ready-for-pickup',
'onclick' => sprintf(
"confirmSetLocation('%s', '%s')",
$message,
$this->getUrl('*/*/notifyPickup')
)
]
);
}
}

/**
* @return bool
*/
private function isEmailsSendingAllowed():bool
{
return $this->_authorization->isAllowed(self::ADMIN_SALES_EMAIL_RESOURCE);
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/InventoryInStorePickupAdminUi/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"magento/framework": "*",
"magento/module-ui": "*",
"magento/module-inventory-in-store-pickup-api": "*",
"magento/module-inventory-admin-ui": "*"
"magento/module-inventory-admin-ui": "*",
"magento/module-sales": "*"
},
"type": "magento2-module",
"license": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<sequence>
<module name="Magento_InventoryInStorePickup" />
<module name="Magento_Shipping" />
<module name="Magento_Sales" />
</sequence>
</module>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\InventoryInStorePickupAdminUi\Block\Adminhtml\Order\View\ReadyForPickup" name="sales_order_ready_for_pickup"/>
</referenceContainer>
</body>
</page>

0 comments on commit 3c78648

Please sign in to comment.