So I think your best bet may be swapping the various events to trigger your own implementations.
What @Dave suggested is a good option, but that's more about changing how the standard templates get sent, where as you want to replace those entirely.
So the 2 email event handlers in Vendr that you'll want to replace are SendFinalizedOrderEmail and SendGiftCardEmails. These are implemented as notification event handlers for the OrderFinalizedNotification event and can be replaced by calling
Then in your handler you can trigger whatever you want to happen, it's worth noting though that there is some logic in these event handlers that you'll have to replicate. It basically makes sure that it should be sending the emails (I can share this with you when needed)
As we don't fire emails for the other events though, you'll need to implement these yourself. The dispatch should be easy enough as you could hook into a OrderStatusChanged event to know when an order is moved into a Dispatched order status. At that point you could trigger the sending of that email.
For abandoned carts though, we don't fire any events for this, so you might need to create a recuring background task to lookup newly abandoned carts. IIRC MailChimp has some form of integration for this, so you might be able to hook into that for it to do it's own monitoring of abandoned carts.
Anywho, I think that should be the general outline of how I would go about it.
The "Send Email" button is tied to Vendr's email templates so you wouldn't be able to hook into that for your own external email system
Technically the action buttons are extendable, so you can add your own, but it's pretty advanced angularjs to do that. Here's the bare bones of it, but like I say, you'll need some angularjs knowledge for this to make sense.
angular.module('vendr').config(["vendrActions", function(vendrActions) {
vendrActions.editorActions.push(['$q', 'myActionResource', function ($q, myActionResource) {
return {
name: 'Send Email', // The name of the menu action
action: function (model) {
return $q(function (resolve, reject) {
// Do your action here. This could include launching dialogs or calling
// external services to trigger some action. Everything should be promise
// based.
// The model variable is an object for the current entity so you can use
// model.id to get the entities ID etc.
// When you are done with your action you should call resolve({ success: true, message: "Email sent" })
// or if your action was canceled call resolve({ canceled: true })
// or reject({ message: msg }); if there was an error
});
},
condition: function (ctx) {
// A condition function to decide whether this item should be displayed or not.
// The ctx variable will contain the storeId and entityType associated with
// this action so from that you can decide whether to display or not.
}
}
}]);
}]);
Handle emails via third party
A client is looking to have the following email notifications handled via a third party i.e. Campaign Monitor, MailChimp, etc.
Basket abandonment Thank you for your order Order dispatched Order rejected Follow up
Appreciate any advice on how this could implemented with Vendr. Further questions may follow.
Hi Sean,
You mean you want those emails to be sent from the 3rd party service and not using the built in email templates service?
Matt
Yes, that is my understanding.
Ok,
So I think your best bet may be swapping the various events to trigger your own implementations.
What @Dave suggested is a good option, but that's more about changing how the standard templates get sent, where as you want to replace those entirely.
So the 2 email event handlers in Vendr that you'll want to replace are
SendFinalizedOrderEmail
andSendGiftCardEmails
. These are implemented as notification event handlers for theOrderFinalizedNotification
event and can be replaced by callingThen in your handler you can trigger whatever you want to happen, it's worth noting though that there is some logic in these event handlers that you'll have to replicate. It basically makes sure that it should be sending the emails (I can share this with you when needed)
As we don't fire emails for the other events though, you'll need to implement these yourself. The dispatch should be easy enough as you could hook into a
OrderStatusChanged
event to know when an order is moved into aDispatched
order status. At that point you could trigger the sending of that email.For abandoned carts though, we don't fire any events for this, so you might need to create a recuring background task to lookup newly abandoned carts. IIRC MailChimp has some form of integration for this, so you might be able to hook into that for it to do it's own monitoring of abandoned carts.
Anywho, I think that should be the general outline of how I would go about it.
Hope that helps
Matt
Can i hook this up into the "Send Order Email" in the backoffice?
Hey Marcus,
The "Send Email" button is tied to Vendr's email templates so you wouldn't be able to hook into that for your own external email system
Technically the action buttons are extendable, so you can add your own, but it's pretty advanced angularjs to do that. Here's the bare bones of it, but like I say, you'll need some angularjs knowledge for this to make sense.
I know some AngularJS even though I am getting a bit rusty with all the Vue etc :).
I will see how to proceed but thanx.
Hi Sean,
There is a interface in Vendr for sending e-mails :
https://vendr.net/docs/core/2.1.0/umbraco-v9/reference/vendr-core/vendr-core-mail/iemailsender/
Maybe you can write your own implementation of that one.
Dave
is working on a reply...