AfterAddItem

This event belongs to the graphql-storefront module. It will be fired after an item is added to basket and holds the ID of the the user basket, ID of the product and the amount.

AfterAddItemEventSubscriber

<?php

declare(strict_types=1);

namespace Full\Qualified\Namespace;

use OxidEsales\EshopCommunity\Internal\Framework\Event\AbstractShopAwareEventSubscriber;
use OxidEsales\GraphQL\Storefront\Basket\Event\AfterAddItem;

class DeveloperAfterAddItemEventSubscriber extends AbstractShopAwareEventSubscriber
{
    public function handle(AfterAddItem $event): AfterAddItem
    {
        //get the user basket id from event
        $userBasketId = (string) $event->getBasketId();

        //get the product id from event
        $productId = (string) $event->getProductId();

        //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\AfterAddItem' => 'handle'
        ];
    }
}

Important

The code above is only an example. In case you need to handle the AfterAddItem event, please adapt to your needs.

services.yaml

services:

    _defaults:
        public: false
        autowire: true

    Full\Qualified\Namespace\DeveloperAfterAddItemEventSubscriber:
        class: Full\Qualified\Namespace\DeveloperAfterAddItemEventSubscriber
        tags: ['kernel.event_subscriber']