Closed mironcat closed 5 years ago
You have to add a listener in your application's EventServiceProvider, that listens to the OrderWasCreated
event. See an example here: https://github.com/vanilophp/framework/blob/master/src/Providers/EventServiceProvider.php
Please let me know if it worked or if you need more guidance.
Thank you! I will try and write this if it worked or not
I'm a absolutely newbie at the Laravel. I create and register the file of lisener:
\app\Listeners\OrderListener.php but now I have an error: Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR) Argument 1 passed to App\Listeners\OrderListener::handle() must be an instance of App\Events\Vanilo\Order\Events\OrderWasCreated, instance of Vanilo\Order\Events\OrderWasCreated given
at the listener:
// \app\Listeners\OrderListener.php
class OrderListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param OrderWasCreated $event
* @return void
*/
public function handle(OrderWasCreated $event)
{
//
$order = $event->getOrder();
dd($order);
}
}
Add
use Vanilo\Order\Events\OrderWasCreated;
to the list of use clauses in the OrderListener.php
file
Thank you! It works!
Is it possible to receive an email when a new product order? I didn't find anything about it in the documentation. Thank you for this interesting project!