-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Ready for Pickup" button on the Order page in Admin Panel which …
…notifies Customer that Order could be picked up #2034. NotifyOrderIsReadyAndShipInterface API; Implemented NotifyPickup controller; Added some TODOs
- Loading branch information
Showing
8 changed files
with
201 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/code/Magento/InventoryInStorePickup/Model/NotifyOrderIsReadyAndShip.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryInStorePickup\Model; | ||
|
||
use Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface; | ||
use Magento\InventoryInStorePickupApi\Api\NotifyOrderIsReadyAndShipInterface; | ||
use Magento\InventoryInStorePickupApi\Exception\OrderIsNotReadyForPickupException; | ||
|
||
class NotifyOrderIsReadyAndShip implements NotifyOrderIsReadyAndShipInterface | ||
{ | ||
/** | ||
* @var \Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface | ||
*/ | ||
private $isOrderReadyForPickup; | ||
|
||
/** | ||
* @var \Magento\Sales\Api\ShipOrderInterface | ||
*/ | ||
private $shipOrder; | ||
|
||
/** | ||
* NotifyOrderIsReadyAndShip constructor. | ||
* | ||
* @param \Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface $isOrderReadyForPickup | ||
* @param \Magento\Sales\Api\ShipOrderInterface $shipOrder | ||
*/ | ||
public function __construct( | ||
IsOrderReadyForPickupInterface $isOrderReadyForPickup, | ||
\Magento\Sales\Api\ShipOrderInterface $shipOrder | ||
) { | ||
$this->isOrderReadyForPickup = $isOrderReadyForPickup; | ||
$this->shipOrder = $shipOrder; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute(int $orderId):int | ||
{ | ||
if (!$this->isOrderReadyForPickup->execute($orderId)) { | ||
throw new OrderIsNotReadyForPickupException(); | ||
} | ||
|
||
/* TODO: send email */ | ||
|
||
return $this->shipOrder->execute($orderId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/code/Magento/InventoryInStorePickupApi/Api/NotifyOrderIsReadyAndShipInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\InventoryInStorePickupApi\Api; | ||
|
||
interface NotifyOrderIsReadyAndShipInterface | ||
{ | ||
/** | ||
* @param int $orderId | ||
* | ||
* @return int Id of created Shipment | ||
* | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
* @throws \Magento\InventoryInStorePickupApi\Exception\OrderIsNotReadyForPickupException | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function execute(int $orderId):int; | ||
} |
34 changes: 34 additions & 0 deletions
34
app/code/Magento/InventoryInStorePickupApi/Exception/OrderIsNotReadyForPickupException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryInStorePickupApi\Exception; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Phrase; | ||
|
||
/** | ||
* Class OrderIsNotReadyForPickupException | ||
* | ||
* @package Magento\InventoryInStorePickupApi\Exception | ||
* @api | ||
*/ | ||
class OrderIsNotReadyForPickupException extends LocalizedException | ||
{ | ||
/** | ||
* @param \Magento\Framework\Phrase $phrase | ||
* @param \Exception $cause | ||
* @param int $code | ||
*/ | ||
public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0) | ||
{ | ||
if ($phrase === null) { | ||
$phrase = new Phrase('The order is not ready for pickup'); | ||
} | ||
|
||
parent::__construct($phrase, $cause, $code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters