Expose Availability Checkers in the Admin UI

Created on 22 April 2025, 4 months ago

Describe your bug or feature request.

Introducing new availability checkers directly into Commerce Core can break existing stores if they’re enabled by default (see issue Add an availability checker which checks if the entity is accessible or not Needs work ).
Site builders also need a straightforward way to enable or disable individual availability rules without writing custom service overrides.

Proposal

  • Introduce AvailabilityCheckerWithMetadataInterface that availability checkers may implement to expose themselves in the admin UI via provided labels and descriptions.
  • Add an “Availability” section under Store → Configuration → Order settings.
  • In this section, list all availability checkers implementing AvailabilityCheckerWithMetadataInterface, providing checkboxes to enable or disable each individually.
  • Legacy availability checkers (those without metadata support) remain hidden from the UI and always execute. A deprecation notice will be dispatched to encourage maintainers to adopt the metadata interface before Commerce 4.
  • Preserve the execution order of all checkers via service weight.
  • Core‑shipped checkers implementing AvailabilityCheckerWithMetadataInterface (see Add an availability checker which checks if the entity is accessible or not Needs work ) should be:
    • Enabled by default on new sites
    • Disabled by default on existing sites
Feature request
Status

Active

Version

3.0

Component

Order

Created by

🇳🇴Norway zaporylie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @zaporylie
  • 🇳🇴Norway zaporylie

    I published the MR with the proof of concept. Below is a screenshot from UI with the exposed checker from Add an availability checker which checks if the entity is accessible or not Needs work .

  • Pipeline finished with Failed
    4 months ago
    Total: 580s
    #479581
  • Pipeline finished with Failed
    4 months ago
    Total: 343s
    #479899
  • Pipeline finished with Failed
    4 months ago
    #479987
  • 🇮🇱Israel jsacksick

    Just one word regarding the UI. I believe the helper text should appear before the options, to at least be consistent with the order version mismatch setting.

  • Pipeline finished with Failed
    4 months ago
    Total: 528s
    #480211
  • 🇮🇱Israel jsacksick

    @zaporylie: I kind of changed my mind on this and I now believe we should explore the attributes route as we're here providing metadata which is the right use case for this.
    Additionally, I think we should provive an update hook that sets the config based on the available checkers for BC reasons so we don't have to worry about the existing and have conditional logic...

    Thoughts?

  • 🇳🇴Norway zaporylie

    I came to the same conclusion about utilizing a custom Metadata attribute. Additionally, I believe the metadata could also include an ID (separate from the service name), which would then be used in the config sequence to mark the checker as enabled or disabled.

    I also think that filtering of checkers should happen in the constructor (as originally proposed) to avoid the performance overhead of limiting the list repeatedly during each call to AvailabilityManagerInterface::check.

    The main advantage of using tagged services over plugins is better performance, as tagged services are collected during the container build phase. Introducing extra filtering steps at runtime for every pass would be suboptimal. This approach would only make sense if we were using plugins, which we are not.

  • Pipeline finished with Failed
    3 months ago
    Total: 597s
    #484094
  • 🇳🇴Norway zaporylie

    I’ve updated the PR to use the attribute approach. Generally, it’s working, but there’s a major flaw in the architecture.

    Because of how the container works, a single class can represent multiple services. With an immutable Attribute, we lose the ability to vary metadata per service instance.

    Given that, I’m considering moving back to the interface approach but using a Metadata value object to keep things cleaner and more structured.

  • Pipeline finished with Failed
    3 months ago
    Total: 629s
    #484726
  • Pipeline finished with Failed
    3 months ago
    #485797
  • 🇳🇴Norway zaporylie

    We had an internal discussion that triggered a small but mighty change to the scope of this issue. The idea is to toggle availability checkers on a per-order-item-type basis.
    The MR is now updated accordingly.

Production build 0.71.5 2024