Event like EVENT_BEFORE_ADD_LINE_ITEM that covers CP additions #2493
Replies: 2 comments
-
@GaryReckard unfortunately I dont't have an answer but are you able to share the code you use to "keep two types of products from existing in a cart at a time". This is exactly what I'm trying to do. |
Beta Was this translation helpful? Give feedback.
-
Hi @StijnCoolen Sure! So, In my custom module, I have a line
And in that
Making use of Behaviors on LineItem and Order (cart), that look something like this one on LineItem, for instance:
That LineItemBehavior is defined in my module like so:
... Also have a similar behavior on the Order class. Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
I’m using the
Order::EVENT_BEFORE_ADD_LINE_ITEM
event to do several things, one of which is to keep two types of products from existing in a cart at a time, or blocking a certain line-item if the user meets certain criteria.This works great for when a user adds the line item on the front-end… but this doesn’t seem to get triggered when an admin adds a line item in the CP when manually creating an order. Anybuddy know of a similar event that will catch admin additions in the CP, or another route to take for that?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions