postAddProductToCollection

The postAddProductToCollection hook is triggered after a product is added to the cart and can be used to perform additional actions.

Parameters

  1. \Isotope\Model\ProductCollectionItem $product

    The product collection item that was added to the collection.

  2. int $quantity

    The quantity of the product that was added to the collection.

  3. \Isotope\Interfaces\IsotopeProductCollection $collection

    The collection the product was added to.

  4. array $config

    The model configuration.

Example

// src/EventListener/Isotope/PostAddProductToCollectionListener.php
namespace App\EventListener\Isotope;

use Isotope\Interfaces\IsotopeProduct;
use Isotope\Interfaces\IsotopeProductCollection;
use Isotope\ServiceAnnotation\IsotopeHook;

/**
 * @IsotopeHook("postAddProductToCollection")
 */
class PostAddProductToCollectionListener 
{
    public function __invoke(ProductCollectionItem $item, $quantity, IsotopeProductCollection $collection, array $config): void
    {
        // Do something …
    }
}

References