I am using a customer segment to determine which customers are eligible to use a discount code. The segment checks multiple metafields on the customer. And according to Shopify documentation, they should update to include the relevant customers automatically.
The customer segment definition query looks something like this:
(metafields.system.condition = true AND metafields.system.type = 'discount') AND (metafields.system.discount_already_used != true)
Modifying the test customer’s metafields demonstrates that the segment reports correctly. Specifically, when all conditions are true, the test customer is included, and when one is false, the customer is omitted.
Despite the above, an inconsistency arises at checkout. Even if the segment indicates zero customers, the discount still applies to the test customer. The same issues occurs in a different scenario, if the segment definition changes. The customer starts out in the segment, the segment definition changes and no customers are shown, but the discount code still works for that customer at checkout.
There either seems to be a bug, caching issue, or something I’m fundamentally misunderstanding here.
I thought customer segments were a reliable way to determine if a customer is eligible to use a discount. But, I’ve been told that the behavior described is by design. Specifically, that the discount code is intentionally accepted if the “customer segment check fails”, to prevent the possible rejection of a valid code.
However, in different test scenarios, the discount application with customer segments behaves as expected. It’s only in more complex situations, like I described above, that issues arise. This makes me think this is a bug or caching issue.
If it’s truly intended to accept a discount code even when a customer doesn’t fit within a specified segment, it seems counterintuitive to the purpose of using segments to determine customer eligibility for discount codes.
Any feedback on this is much appreciated!