Make it possible to not display the add to cart message when using ajax

Created on 1 February 2019, almost 6 years ago
Updated 8 April 2023, over 1 year ago

Currently, the best way to remove the "item added to cart" message when making sure the item is added via ajax, is overriding the commerce_cart.cart_subscriber service. For example with a service provider or decorator.

It would be nice if this was part of core commerce, somehow.

I see a few possible solutions:

- Actually add a check on this in the CartEventSubscriber class. I imagine most people adding things to the cart via ajax either removes this already, or wished it was removed. However, this is speculative.
- Add a setting for commerce to do this (sitewide).
- Add a property on the order type entity to toggle it. We could even extend it to be able to toggle it off completely, if someone wanted that, for some reason (I imagine if someone is adding items via a custom form, say they are adding 20 items, and not using ajax, they might want to clean up those status messages somehow). This property could be set to FALSE by default, providing an upgrade path with the old behavior intact.

Thoughts?

Feature request
Status

Needs review

Version

2.0

Component

Developer experience

Created by

🇳🇴Norway eiriksm Norway

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.

Production build 0.71.5 2024