Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sean Dooley 288 posts 527 karma points
    May 24, 2022 @ 13:17
    Sean Dooley
    0

    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.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    May 24, 2022 @ 13:28
    Matt Brailsford
    0

    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

  • Sean Dooley 288 posts 527 karma points
    May 24, 2022 @ 14:09
    Sean Dooley
    0

    Yes, that is my understanding.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    May 24, 2022 @ 14:26
    Matt Brailsford
    100

    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 and SendGiftCardEmails. These are implemented as notification event handlers for the OrderFinalizedNotification event and can be replaced by calling

    builder.WithNotificationEvent<OrderFinalizedNotification>()
        .ReplaceHandler<SendFinalizedOrderEmail, MySendFinalizedOrderEmail>()
        .ReplaceHandler<SendGiftCardEmails, MySendGiftCardEmails>();
    

    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.

    Hope that helps

    Matt

  • Marcus Maunula 229 posts 386 karma points
    Jun 10, 2022 @ 11:37
    Marcus Maunula
    0

    Can i hook this up into the "Send Order Email" in the backoffice?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jun 10, 2022 @ 12:52
    Matt Brailsford
    0

    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.

    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.
    
                }
            }
        }]);
    
    }]);
    
  • Marcus Maunula 229 posts 386 karma points
    Jun 11, 2022 @ 13:19
    Marcus Maunula
    1

    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.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    May 24, 2022 @ 13:28
    Dave Woestenborghs
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft