AfterRemoveItem
This event belongs to the graphql-storefront module. It will be fired after an item is remove from basket and holds the ID of the the user basket, ID of the basket item for remove and amount.
AfterRemoveItemEventSubscriber
<?php
declare(strict_types=1);
namespace Full\Qualified\Namespace;
use OxidEsales\GraphQL\Storefront\Basket\Event\AfterRemoveItem;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class DeveloperAfterRemoveItemEventSubscriber implements EventSubscriberInterface
{
public function handle(AfterRemoveItem $event): AfterRemoveItem
{
//get the user basket id from event
$userBasketId = (string) $event->getBasketId();
//get the user basket item id from event
$basketItemId = (string) $event->getBasketItemId();
//get the user basket item amount from event
$amount = (float) $event->getAmount();
//do something
return $event;
}
public static function getSubscribedEvents()
{
return [
'OxidEsales\GraphQL\Storefront\Basket\Event\AfterRemoveItem' => 'handle'
];
}
}
Important
The code above is only an example. In case you need to handle the AfterRemoveItem
event,
please adapt to your needs.
services.yaml
services:
_defaults:
public: false
autowire: true
Full\Qualified\Namespace\DeveloperAfterRemoveItemEventSubscriber:
class: Full\Qualified\Namespace\DeveloperAfterRemoveItemEventSubscriber
tags: ['kernel.event_subscriber']