Simple Commerce Logo

Notifications

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.

Configuration

1/*
2|--------------------------------------------------------------------------
3| Notifications
4|--------------------------------------------------------------------------
5|
6| Simple Commerce can automatically send notifications after events occur in your store.
7| eg. a cart being completed.
8|
9| Here's where you can toggle if certain notifications are enabled/disabled.
10|
11| https://simple-commerce.duncanmcclean.com/notifications
12|
13*/
14 
15'notifications' => [
16 'order_paid' => [
17 \DoubleThreeDigital\SimpleCommerce\Notifications\CustomerOrderPaid::class => [
18 'to' => 'customer',
19 ],
20 \DoubleThreeDigital\SimpleCommerce\Notifications\BackOfficeOrderPaid::class => [
21 'to' => 'duncan@example.com',
22 ],
23 ],
24],

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.

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 ],
5],
  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.

Need some help?

There's plenty of ways of getting help: either via opening a GitHub Issue, starting a conversation on the Statamic Discord or directly emailing me.