Manager/PriceCalculationManager.php
public function retrieveItemPrices($itemsData, $currency, $locale)
    {
        $items = [];
        $previousItem = null;

        // Prepare item data.
        foreach ($itemsData as $itemData) {
            $useProductsPrice = false;
            if (isset($itemData['useProductsPrice']) && $itemData['useProductsPrice'] == true) {
                $useProductsPrice = $itemData['useProductsPrice'];
            }

            // Add and remove necessary data for calculation.
            $itemData = $this->setDefaultData($itemData);
            $itemData = $this->unsetUneccesaryData($itemData);

            // Generate item.
            /** @var ItemInterface $item */
            $item = $this->getItemManager()->save($itemData, $locale, null, null, null, null, $previousItem);
            $item->setUseProductsPrice($useProductsPrice);

            // Calculate total net price of item.
            $itemPrice = $this->itemPriceCalculator->calculateItemNetPrice(
                $item,
                $currency,
                $useProductsPrice,
                $this->isItemGrossPrice($itemData)
            );
            $itemTotalNetPrice = $this->itemPriceCalculator->calculateItemTotalNetPrice(
                $item,
                $currency,
                $useProductsPrice,
                $this->isItemGrossPrice($itemData)
            );
            $item->setPrice($itemPrice);
            $item->setTotalNetPrice($itemTotalNetPrice);

            // Save the last processed product item to calculate addon prices.
            if (Item::TYPE_ADDON !== $item->getType()) {
                $previousItem = $item->getEntity();
            }

            $items[] = $item;
        }

        return [
            'items' => $items,
        ];
    }
public function retrieveItemPrices($itemsData, $currency, $locale)
    {
        $items = [];
        $previousItem = null;

        // Prepare item data.
        foreach ($itemsData as $itemData) {
            $useProductsPrice = false;
            if (isset($itemData['useProductsPrice']) && $itemData['useProductsPrice'] == true) {
                $useProductsPrice = $itemData['useProductsPrice'];
            }

            // Add and remove necessary data for calculation.
            $itemData = $this->setDefaultData($itemData);
            $itemData = $this->unsetUneccesaryData($itemData);

            // Generate item.
            /** @var ItemInterface $item */
            $item = $this->getItemManager()->save($itemData, $locale, null, null, null, null, $previousItem);
            $item->setUseProductsPrice($useProductsPrice);

            // Calculate total net price of item.
            $itemPrice = $this->itemPriceCalculator->calculateItemNetPrice(
                $item,
                $currency,
                $useProductsPrice,
                $this->isItemGrossPrice($itemData)
            );
            $itemTotalNetPrice = $this->itemPriceCalculator->calculateItemTotalNetPrice(
                $item,
                $currency,
                $useProductsPrice,
                $this->isItemGrossPrice($itemData)
            );
            $item->setPrice($itemPrice);
            $item->setTotalNetPrice($itemTotalNetPrice);

            // Save the last processed product item to calculate addon prices.
            if (Item::TYPE_ADDON !== $item->getType()) {
                $previousItem = $item->getEntity();
            }

            $items[] = $item;
        }

        return [
            'items' => $items,
        ];
    }
public function retrieveItemPrices ( $ itemsData , $ currency , $ locale ) { $ items = [ ] ; $ previousItem = null ; // Prepare item data. foreach ( $ itemsData as $ itemData ) { $ useProductsPrice = false ; if ( isset ( $ itemData [ 'useProductsPrice' ] ) && $ itemData [ 'useProductsPrice' ] == true ) { $ useProductsPrice = $ itemData [ 'useProductsPrice' ] ; } // Add and remove necessary data for calculation. $ itemData = $ this -> setDefaultData ( $ itemData ) ; $ itemData = $ this -> unsetUneccesaryData ( $ itemData ) ; // Generate item. /** @var ItemInterface $item */ $ item = $ this -> getItemManager ( ) -> save ( $ itemData , $ locale , null , null , null , null , $ previousItem ) ; $ item -> setUseProductsPrice ( $ useProductsPrice ) ; // Calculate total net price of item. $ itemPrice = $ this -> itemPriceCalculator -> calculateItemNetPrice ( $ item , $ currency , $ useProductsPrice , $ this -> isItemGrossPrice ( $ itemData ) ) ; $ itemTotalNetPrice = $ this -> itemPriceCalculator -> calculateItemTotalNetPrice ( $ item , $ currency , $ useProductsPrice , $ this -> isItemGrossPrice ( $ itemData ) ) ; $ item -> setPrice ( $ itemPrice ) ; $ item -> setTotalNetPrice ( $ itemTotalNetPrice ) ; // Save the last processed product item to calculate addon prices. if ( Item :: TYPE_ADDON !== $ item -> getType ( ) ) { $ previousItem = $ item -> getEntity ( ) ; } $ items [ ] = $ item ; } return [ 'items' => $ items , ] ; }
Calculates total prices of all items given in data array.

@param array $itemsData
@param string $currency
@param string $locale

@return array
Calculates total prices of all items given in data array .