Dispatch an Event from the AvailabilityOrderProcessor

Created on 6 February 2020, almost 5 years ago
Updated 2 September 2024, 2 months ago

Problem/Motivation

Currently when a purchased entity become unavailable, it is simply removed from the order by the AvailabilityOrderProcessor with the availabilityManager service.

There is no way to display a message, or even perform another action without swapping this OrderProcessor.

Proposed resolution

Instead of remove the order item for which the purchased entity is unavailable, we could dispatch a new Event AvailabilityEvent, and provide a default Event Subscriber wich perform the same existing action : remove the order item form the order.

Others modules could then also subscribe to this Event and display a message or doing what is needed for a project.

Remaining tasks

  • Agree on the changement
  • Discuss about the default Event subscriber to implement (should we add a message about the item removed to client)
  • Write patch

User interface changes

None

API changes

An new Event si created : AvailabilityEvent
The AvailabilityOrderProcessor get a new argument (the eventDispatcher) and so this breaks BC.

Data model changes

None

Feature request
Status

Needs review

Version

2.0

Component

Order

Created by

🇫🇷France flocondetoile Lyon

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇴Norway zaporylie

    I am unsure if the AvailabilityOrderProcessor is the right place to dispatch the event. if it's dispatched from somewhere I think it should be the AvailabilityManager itself.

    Frankly, I am not sold on the idea of removing unavailable order items from the cart either. I think this results in very bad UX, especially when an order item is deleted programmatically without the customer really noticing it. This could be a problem, especially if the average cart contains many order items with low prices and low quantities, like groceries, etc. In such case the customer might not even notice that items were removed.

    In fact, all projects that I implemented in the recent past had the AvailabilityOrderProcessor removed altogether because of that non-optimal UX behavior.

    I think a possibly better way to approach this is to label unavailable order items as such during AvailabilityOrderProcessor run If order item is not available prevent checkout completion rather than deleting it from cart Active

  • 🇦🇹Austria agoradesign

    agree. this leads me thoughts into the direction that it would be nice to have the possiblity to add some kind of messages to a cart. Like "item XY is not available anymore. Please remove it from your cart..." or maybe then we even could remove it, but show the message to the customer... or like Amazon notify of price changes. afaik, there's already an issue for this

Production build 0.71.5 2024