Notifications are a must for any e-commerce store, especially email notifications. Simple Commerce hooks into Laravel's Notification's feature to send notifications.

With this, you can send notifications via email, via SMS or even in real time if you use the broadcast driver.


3| Notifications
6| Simple Commerce can automatically send notifications after events occur in your store.
7| eg. a cart being completed.
9| Here's where you can toggle if certain notifications are enabled/disabled.
15'notifications' => [
16 'order_paid' => [
17 \DoubleThreeDigital\SimpleCommerce\Notifications\CustomerOrderPaid::class => [
18 'to' => 'customer',
19 ],
20 \DoubleThreeDigital\SimpleCommerce\Notifications\BackOfficeOrderPaid::class => [
21 'to' => '',
22 ],
23 ],
25 // ...

Inside the notifications array, you can list the event you would like to send notifications on, then you can provide another array with each of the notifications you'd like to send when that event happens.

You may also configure who you wish to send each notification to. If you'd like to send the notification to a customer, send it to the customer. Otherwise, you can simply send it to an email address.

Available events

You may listen to any of the following events:

  • order_paid
  • order_payment_failed
  • order_shipped
  • stock_running_low
  • stock_run_out

Using a custom notification

If you want to change the text used in the notification or maybe provide more information about the order, using a custom notification is the best way to do that.

Here's a quick rundown of how to generate your own notification and configure it to be used by Simple Commerce.

  1. Generate a notification
1php artisan make:notification OrderPaidNotification
  1. In your simple-commerce.php config file, switch out the previous class for your new one.
1'notifications' => [
2 'order_paid' => [
3 \App\Notifications\OrderPaidNotification::class => ['to' => 'customer'],
4 ],
  1. Copy over pretty much everything from the default notification we provide and paste it into your new notification class.

  2. Make whatever changes you need to make!

Customising the email views

Simple Commerce uses the default email views provided by Laravel. You may publish these views to your resources/views/vendor directory using the following command:

1php artisan vendor:publish --tag=laravel-notifications

Testing emails

While you're in development, you may need to test your emails without faffing around with real emails.

For this, I'd recommend using a tool like HELO or Mailtrap which let you view emails during development.

Disclaimer: The HELO link is a 30% affiliate link.