# Filtering Abandoned Carts E-mails in Commerce

**URL:** <https://forum.umbraco.com/t/filtering-abandoned-carts-e-mails-in-commerce/8118>\
**Category:** Questions\
**Tags:** umbraco-commerce, v17\
**Created:** [May 26, 2026, 1:25pm UTC](https://forum.umbraco.com/t/filtering-abandoned-carts-e-mails-in-commerce/8118 "2026-05-26T13:25:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![justin-nevitech](https://forum.umbraco.com/user_avatar/forum.umbraco.com/justin-nevitech/32/6219_2.png) [@justin-nevitech](https://forum.umbraco.com/u/justin-nevitech)\
**Post date:** [May 27, 2026, 8:23am UTC](https://forum.umbraco.com/t/filtering-abandoned-carts-e-mails-in-commerce/8118/2 "2026-05-27T08:23:53Z")

</div>

Hi @cryothic

I had a look at the docs and I can’t see anything that allows you to change the logic or cancel an abandoned cart email. Your best option would be to disable the built-in mechanism and write your own using the `CartAbandonedNotification` event.

Here’s the solution AI came back with:

You’re right that `EmailSendingNotification` is a dead end here — it doesn’t give you a way to cancel the send, so you can’t filter from there.

The cleaner approach is to handle the `CartAbandonedNotification` event instead and do the sending yourself, so you’re in full control of who gets an email. The trick is that this works in two parts:

1. **Clear the Abandoned Cart Email Template** in Store Settings \> Cart Settings. With no template set, Commerce stops sending its own email, but detection keeps running and the notification still fires. This is what lets you take over the send.
2. **Handle `CartAbandonedNotification`** , loop the order IDs, resolve the member, check your flag, and only send to those who haven’t opted out.

The registration has to go _inside_ the `AddUmbracoCommerce(...)` callback in a composer — that’s a common gotcha; registered on the bare `IUmbracoBuilder` it compiles but never fires:

```csharp
public class CommerceComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.AddUmbracoCommerce(commerceBuilder =>
        {
            commerceBuilder
                .WithNotificationEvent<CartAbandonedNotification>()
                .RegisterHandler<AbandonedCartHandler>();
        });
    }
}

```

And the handler, with the member-flag check:

```csharp
public class AbandonedCartHandler : NotificationEventHandlerBase<CartAbandonedNotification>
{
    private readonly IServiceProvider _serviceProvider;

    public AbandonedCartHandler(IServiceProvider serviceProvider)
        => _serviceProvider = serviceProvider;

    public override void Handle(CartAbandonedNotification evt)
    {
        using var scope = _serviceProvider.CreateScope();
        var orderService = scope.ServiceProvider.GetRequiredService<IOrderService>();
        var memberService = scope.ServiceProvider.GetRequiredService<IMemberService>();

        foreach (var orderId in evt.OrderIds)
        {
            var order = orderService.GetOrder(orderId);
            if (order?.CustomerInfo is null) continue;

            // however you've stored the member reference on the order at checkout
            if (!Guid.TryParse(order.CustomerInfo.CustomerReference, out var memberKey))
                continue; // guest checkout -> skip

            var member = memberService.GetByKey(memberKey);
            if (member is null) continue;

            // opt-out style: skip if they've ticked the box
            if (member.GetValue<bool>("disallowAbandonedCartEmail")) continue;

            // (or opt-in: if (!member.GetValue<bool>("allowAbandonedCartEmail")) continue;)

            // send your email here
        }
    }
}

```

Two things to check on your side:

- How the member is attached to the order at checkout. I’ve used `CustomerInfo.CustomerReference` above, but check what you actually set when the member places the order — it might be a custom order property or an email match against `IMemberService`. That lookup is the bit to get right.
- One honest caveat: I’m confident clearing the template stops the native send (the docs note that with no template, no email goes out but notifications/webhooks still fire), but I haven’t seen it confirmed whether the notification fires _alongside_ the built-in send or _instead_ of it. So test it — clear the template, trigger an abandoned cart, and make sure no duplicate native email goes out. If it does, we can dig further.

The one trade-off is you lose the built-in conversion-rate widget tracking, since that’s tied to Commerce sending the email itself. If you rely on that, worth factoring in.

Hope that helps!

Justin

---

_[View the full topic](https://forum.umbraco.com/t/filtering-abandoned-carts-e-mails-in-commerce/8118)._
