craftcms / craftcms/commerce

[5.x]: Can discounts Match Customer check against a completely anonymous cart

Open
#4,156 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

💡 enhancement commerce5 Craft Commerce
Dominant language
PHP
Stars
240
Forks
173
Avg merge
5d 11h
Merged PRs (30d)
8

Description

What happened?
Description

Current behaviour dictates that as soon as you create one rule in a customer condition on a discount this requires the cart must have a customer on it (even if they are a guest/non-credentialed user).

This works for the most part but does somewhat require that the email address for a cart is taken early in the process.

For example, somewhere this logic falls down is if a discount:

  • has a coupon code
  • has user group customer condition rule "where user is not in group XYZ"

If the coupon code is entered earlier than the email then this fails, even though logic may suggest an anonymous customer who is yet to provide those details is not in that group.

Craft CMS version

5.x

Craft Commerce version

5.x

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the discount customer-condition evaluation for a cart where the coupon code is entered before the email address. Reproduce the user-group rule "where user is not in group XYZ" on an anonymous cart, then verify that the condition can be evaluated without requiring customer details first.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.