Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ready for pickup button on the order page in admin panel which notifies customer that order could be picked up 2034 #2127

Conversation

novikor
Copy link
Contributor

@novikor novikor commented Apr 1, 2019

Description (*)

  • New API:

    • \Magento\InventoryInStorePickupApi\Api\IsOrderReadyForPickupInterface;
    • \Magento\InventoryInStorePickupApi\Api\NotifyOrderIsReadyAndShipInterface;
  • Added 'Notify Order is Ready for Pickup' button;

  • Notify customer using custom email template

  • Ship the order after the notification to reserve QTY

Fixed Issues (if relevant)

  1. Add "Ready for Pickup" button on the Order page in Admin Panel which notifies Customer that Order could be picked up #2034: Add "Ready for Pickup" button on the Order page in Admin Panel which notifies Customer that Order could be picked up

Manual testing scenarios (*)

Life is too short for that

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

novikor added 7 commits March 28, 2019 21:00
…notifies Customer that Order could be picked up #2034.

Added the button itself
…notifies Customer that Order could be picked up #2034.

Added check if order is ready for pickup
…notifies Customer that Order could be picked up #2034.

Moved IsOrderReadyForPickup to API level.
Created an init point for NotifyPickup controller.
…notifies Customer that Order could be picked up #2034.

NotifyOrderIsReadyAndShipInterface API;
Implemented NotifyPickup controller;
Added some TODOs
…notifies Customer that Order could be picked up #2034.

Added canShip() check to IsOrderReadyForPickup;
Added TODO
…notifies Customer that Order could be picked up #2034.

Implemented synchronous email sending with custom email template for storepickup.
Added even more TODOs
…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

namespace Magento\InventoryInStorePickupAdminUi\Model;

class IsDisplayReadyForPickupButton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display. May replace by Render

@novikor
Copy link
Contributor Author

novikor commented Apr 5, 2019

All the points seem to be fixed.
Please recheck.

I suggest to implement asynchronous email and tests coverage in separate Issues/PRs.

@ishakhsuvarov
Copy link
Contributor

@novikor I agree with implementing those items separately. This PR is already growing out of control

use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;

class IsOrderReadyForPickup implements IsOrderReadyForPickupInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indicate clear purpose of each class in docblock.

While class name looks like it speaks for itself, as a someone who is new to Store Pickup I wouldn't know the conditions for that.

PS: This applies to every class, interface and method hereafter

Copy link
Contributor Author

@novikor novikor Apr 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for all the classes and most of the methods (except execute).

private $orderRepository;

/**
* NotifyOrderIsReadyAndShip constructor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminated.

/** @noinspection PhpParamsInspection */
$this->emailNotifier->notify($this->orderRepository->get($orderId));

/* TODO: add order comment? */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea. I think it was discussed on one of the meetings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I`ll create an issue

throw new OrderIsNotReadyForPickupException();
}

/** @noinspection PhpParamsInspection */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, I could use instanceof to do not send the email or throw an exception instead of a fatal error.
But anyway more likely I will kill the notifier class in the nearest future, so it is OK

}

/**
* {@inheritdoc}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminated.

public function execute(OrderInterface $order): bool
{
if ($order->getExtensionAttributes()
&& $sourceCode = $order->getExtensionAttributes()->getPickupLocationCode()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it only me or assignments inside conditional statements are not that good for readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I really like doing that and like to save the code lines and avoid the code duplicating.

However, I`ve created a poll and realized that nobody likes that.
So, - fixed.

private $eventManager;

/**
* ReadyForPickupSender constructor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminated.

private $isDisplayButton;

/**
* ReadyForPickup constructor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminated.

private $logger;

/**
* NotifyPickup constructor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminated.

…tifies customer that order could be picked up 2034.

Simplified Fully Qualified names
@novikor novikor force-pushed the Add-Ready-for-Pickup-button-on-the-Order-page-in-Admin-Panel-which-notifies-Customer-that-Order-could-be-picked-up-2034 branch from 154ccff to 80d20e9 Compare April 6, 2019 10:17
Maksym Novik added 4 commits April 6, 2019 13:19
…tifies customer that order could be picked up 2034.

CanBeFulfilled -> IsFulfillable
…tifies customer that order could be picked up 2034.

Killed OrderIsNotReadyForPickupException
…tifies customer that order could be picked up 2034.

Just another PHPDocs improvement
…tifies customer that order could be picked up 2034.

Stopped declaring variables inside if condition
…rder-page-in-Admin-Panel-which-notifies-Customer-that-Order-could-be-picked-up-2034
@@ -25,4 +25,14 @@
</argument>
</arguments>
</type>

<preference for="\Magento\InventoryInStorePickupApi\Api\NotifyOrderIsReadyForPickupInterface"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid leading slashes in di configuration

*
* @package Magento\InventoryInStorePickupAdminUi\Controller\Adminhtml\Order
*/
class NotifyPickup extends Action
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name is slightly misleading. It's notify and ship in reality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But...
image

 - Minor coding style improvements
 - Static testing results applied
@ishakhsuvarov ishakhsuvarov merged commit 96d208f into store-pickup Apr 11, 2019
@ghost
Copy link

ghost commented Apr 11, 2019

Hi @novikor, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@novikor novikor deleted the Add-Ready-for-Pickup-button-on-the-Order-page-in-Admin-Panel-which-notifies-Customer-that-Order-could-be-picked-up-2034 branch April 11, 2019 14:58
swnsma pushed a commit that referenced this pull request Apr 24, 2019
ishakhsuvarov added a commit that referenced this pull request Apr 25, 2019
@ishakhsuvarov ishakhsuvarov added this to the Store Pickup Support milestone May 30, 2019
@ishakhsuvarov ishakhsuvarov removed this from the Store Pickup Support milestone Sep 10, 2019
ishakhsuvarov added a commit that referenced this pull request Nov 22, 2019
 - Minor coding style improvements
ishakhsuvarov added a commit that referenced this pull request Nov 22, 2019
 - Static testing results applied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants