Hi guys, we have the events, beforeAddLine/afterAd...
# suitecommerce
e
Hi guys, we have the events, beforeAddLine/afterAddLine, beforeUpdateLine/afterUpdateLine from the Cart Component, do you know if we are able to update any value in data when a line is added, updated when we are suscribed in those events?
s
The event handlers are not set up to allow to you to modify the data and then continue with the modified data. The way I have seen it done is to add the event listener, get the data, cancel the current event, and then start a new one with your modified data. You will need some sort of flag to to prevent your new one from getting interrupted.
e
Hi @Steve Goldberg thanks for the approach, I am tackling this with with some _.wrap in an custom module but out of curiosity, would this be an enhancement in the future? The ability to modify the data in those events would be great.
s
It might be, it kinda depends if that's the direction they want to take it in. At the moment, the
before
events are very much seen as 'cancellable' events, ie ones that are designed to be used to interrupt the event, rather than event and then modify.
e
Yeah, I noticed that. It would be great to update the docs and blogs to say that the data is read-only in those events.
s
Fair point; I will ask the tech writers to clarify
👍 1