Ad

Send Notification To Users When Product Is Created In OctoberCMS?

- 1 answer

I have a plugin that creates a product and I want to send a notification email to all users when a new product has been created, how do i approach this?

Ad

Answer

You could use Events

Fire an event when the product is created and Listen to the respective event to send notification mail to the users.

Event::fire('product.create', [$product]);

Register the listener within the boot method of the plugin

public function boot()
{
    Event::listen('product.create', function ($product) {

       // Send Mail to subscribed users

    });
}
Ad
source: stackoverflow.com
Ad