<?php

    namespace MNM\Spitzner\Plugin;

    class AddCheckoutItemPricePerUnit
    {
        /**
         * @var \MNM\Spitzner\Helper\Data
         */
        private $helper;

        public function __construct(\MNM\Spitzner\Helper\Data $helper)
        {
                $this->helper = $helper;
        }

        /**
         * Modify checkout config data.
         *
         * @param \Magento\Checkout\Model\DefaultConfigProvider $subject
         * @param array $config
         *
         * @return array
         */
        public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $subject, $config)
        {
            foreach ($config['quoteItemData'] as &$item) {
                $item['mnmpriceperunit'] =  $this->helper->getProductPricePerUnit($item['product_id']);
                $item['mnm_spi_inhalt'] =   $this->helper->getSpiInhalt($item['product_id']);
                $item['amstockstatus'] =    $this->helper->getProductAttributeText($item['product_id'], 'custom_stock_status');
            }

            return $config;
        }
    }