BeforeBasketModify

This event belongs to the graphql-storefront module. It will be fired before:

  • delivery address ID

  • delivery method ID

  • payment ID

is set to a basket. It holds the ID of the the user basket and the event type.

BeforeBasketModifyEventSubscriber

<?php

declare(strict_types=1);

namespace Full\Qualified\Namespace;

use OxidEsales\GraphQL\Storefront\Basket\Event\BeforeBasketModify;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class DeveloperBeforeBasketModifyEventSubscriber implements EventSubscriberInterface
{
    public function handle(BeforeBasketModify $event): BeforeBasketModify
    {
        //Get the user basket id from event
        $userBasketId = (string) $event->getBasketId();

        /**
         * Gets the type of the event:
         *
         * 0 = TYPE_NOT_SPECIFIED
         * 1 = TYPE_SET_DELIVERY_ADDRESS
         * 2 = TYPE_SET_DELIVERY_METHOD
         * 3 = TYPE_SET_PAYMENT_METHOD
         */
        $type = $event->getEventType();

        //do something

        return $event;
    }

    public static function getSubscribedEvents()
    {
        return [
            'OxidEsales\GraphQL\Storefront\Basket\Event\BeforeBasketModify' => 'handle'
        ];
    }
}

Important

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

services.yaml

services:

    _defaults:
        public: false
        autowire: true

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