Skip to content

Let a campaign choose customers by whether they have orders - #1129

Open
KrzysztofPajak wants to merge 1 commit into
developfrom
fix/campaign-has-orders-filter
Open

KrzysztofPajak wants to merge 1 commit into
developfrom
fix/campaign-has-orders-filter

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Issue

The Customer has orders condition of a campaign did not work:

  • with another customer condition set (dates, cart, tags, groups), counting the recipients or sending the campaign failed with ExpressionNotSupportedException: Expression not supported: x.IsHasOrders. The helper property it filtered on was get-only and never filled by the query;
  • on its own it was ignored, because the customer conditions were read only when one of the others was set.

Solution

The condition reads the customer's LastPurchaseDateUtc, which OrderPlacedEventHandler sets for every placed order, and it now counts as a customer condition of its own. The unused IsHasOrders property is removed.

Breaking changes

None.

Testing

  1. Create a campaign with Customer has orders = Yes and Customer has shopping cart = No, save it: no error, the recipients are the subscribers who ordered.
  2. Set only Customer has orders = No: the recipients are the subscribers who never ordered.

CampaignServiceTests.CustomerSubscriptions_CustomerHasOrders_KeepsTheMatchingCustomers runs against MongoDB, alone and next to the cart condition; it fails on the old code.

The "customer has orders" condition of a campaign filtered on a helper property that the query
never filled, so counting or sending such a campaign failed with an unsupported expression, and
the condition alone was ignored, as the conditions on customers were only read when another one
was set. It now reads the customer's last purchase date, which every placed order sets, and
counts as a customer condition of its own.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants