# Events
# EnrichLineItemsForVouchersEvent
Currently, only shopping cart items having the flag good
activated are used to calculate the voucher values. If this is deactivated for LineItems (e.g. by third-party plugin line items), we have added an event in version 4.19.0 to add the possibility for plugin manufacturers of adding line items for the calculation.
This event is NetInventors\NetiNextEasyCoupon\Events\EnrichLineItemsForVouchersEvent
.
In order to add your own LineItems, you have to attach yourself to this event, for example in a subscriber:
public static function getSubscribedEvents(): array
{
return [
EnrichLineItemsForVouchersEvent::class => 'onEnrichLineItemsEvent',
];
}
1
2
3
4
5
6
2
3
4
5
6
In the mentioned method, the shopping cart items can be transferred to the event as you can see in the code snippet below, for example:
public function onEnrichLineItemsEvent(EnrichLineItemsForVouchersEvent $event)
{
foreach ($event->getCart()->getLineItems()->filterType('own-type')->getElements() as $lineItem) {
$event->getLineItems()->add($lineItem);
}
}
1
2
3
4
5
6
2
3
4
5
6
The added shopping cart items are now respected by EasyCoupon.