Solidus has a set of mailers which notify some actions such as confirmation of an order, notification when a carton has been already shipped, cancellations, etc. Those notifications were created to keep the customer informed. We can customize these mailers in order to satisfy our business’ needs so we can improve our user experience for the brand identity.
To see the default mailers, in development you can visit /rails/mailers
:
As you can see, the mailers were created in a very simple way, just to share the transactions’ information, but maybe we want to show more (or less) information; and set our brand image and those kinds of things.
Carton shipped email preview
Spree.config
You can set your mailer class for a certain email from the Spree.config
, for example:
- To set a custom shipped_email
(this comes from Spree::CartonMailer) just create your own mailer.
You can use the rails generator (if you want) by doing something like this:
rails generate mailer MyCarton shipped_email
Then just set it as mailer class for shipped_email
:
Spree.config do |config|
...
config.carton_shipped_email_class = MyCartonMailer
...
end
And that's it! (:tada:). If you want, you can use as a guide the original solidus method that you want to customize.
If you want to see how this flexibility can be performed, you can visit the following pull requests:
- Allow customizing the carton mailer class
- Allow customizing the promotion code batch mailer class
- Allow customizing the order mailer class
- Allow customizing the reimbursement mailer class
Conclusion
Solidus is a very powerful project where we can modify its behavior through the configs
without using class_eval
. Another example is the order number generator. You can take a look at this post: Customization Solidus order number generation
Thanks for reading this blogpost. Comments and feedback are more than well-received, and if you want to check my implementation, you can visit this repository.