Hi there.
I’m trying to hook up the abandoned cart email to our external email provider (SendGrid). I’ve followed the documentation for setting up the Abandoned Carts Notification, and I found the CartAbandonedNotification, so I created a handler:
public class UmbracoAbandonedBasket : NotificationEventHandlerBase<CartAbandonedNotification>
{
private readonly IServiceProvider _serviceProvider;
public UmbracoAbandonedBasket(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public override void Handle(CartAbandonedNotification evt)
{
using var scope = \_serviceProvider.CreateScope();
var orderService = scope.ServiceProvider.GetRequiredService<IOrderService>();
var emailService = scope.ServiceProvider.GetRequiredService<IEmailService>();
var siteSettingsService = scope.ServiceProvider.GetRequiredService<ISiteSettingsService>();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<UmbracoAbandonedBasket>>();
foreach (var orderId in evt.OrderIds)
{
//send abandoned cart email asynchronously without awaiting
var task = ProcessAbandonedCart(orderId, orderService, emailService, siteSettingsService, logger);
}
}
DI:
umbracoCommerceBuilder.WithNotificationEvent<CartAbandonedNotification>()
.RegisterHandler<UmbracoAbandonedBasket>();
The issue is that the class above never runs. Umbraco Commerce continues using its built-in abandoned cart email handler.
Is there a way to override or replace the default implementation so I can plug in my own SendGrid based email logic? I suspect I may be approaching this the wrong way.
Thanks a lot for your help!