src/Sulu/Bundle/Sales/CoreBundle/Pricing/ItemPriceCalculator.php
public function calculate($item, $currency = null, $useProductsPrice = true)
    {
        $currency = $this->getCurrency($currency);

        // validate item
        $this->validateItem($item);

        if ($useProductsPrice) {
            $priceValue = $this->getValidProductPriceForItem($item, $currency);
        } else {
            $priceValue = $item->getPrice();
        }
        $this->validateNotNull('price', $priceValue);

        if ($item->getPrice() && $item->getPrice() !== $priceValue) {
            $item->setPriceChange($item->getPrice(), $priceValue);
        }

        $itemPrice = $priceValue * $item->getCalcQuantity();

        // calculate items discount
        $discount = ($itemPrice / 100) * $item->getCalcDiscount();

        // calculate total item price
        $totalPrice = $itemPrice - $discount;

        return $totalPrice;
    }
public function calculate($item, $currency = null, $useProductsPrice = true)
    {
        $currency = $this->getCurrency($currency);

        // validate item
        $this->validateItem($item);

        if ($useProductsPrice) {
            $priceValue = $this->getValidProductPriceForItem($item, $currency);
        } else {
            $priceValue = $item->getPrice();
        }
        $this->validateNotNull('price', $priceValue);

        if ($item->getPrice() && $item->getPrice() !== $priceValue) {
            $item->setPriceChange($item->getPrice(), $priceValue);
        }

        $itemPrice = $priceValue * $item->getCalcQuantity();

        // calculate items discount
        $discount = ($itemPrice / 100) * $item->getCalcDiscount();

        // calculate total item price
        $totalPrice = $itemPrice - $discount;

        return $totalPrice;
    }
public function calculate ( $ item , $ currency = null , $ useProductsPrice = true ) { $ currency = $ this -> getCurrency ( $ currency ) ; // validate item $ this -> validateItem ( $ item ) ; if ( $ useProductsPrice ) { $ priceValue = $ this -> getValidProductPriceForItem ( $ item , $ currency ) ; } else { $ priceValue = $ item -> getPrice ( ) ; } $ this -> validateNotNull ( 'price' , $ priceValue ) ; if ( $ item -> getPrice ( ) && $ item -> getPrice ( ) !== $ priceValue ) { $ item -> setPriceChange ( $ item -> getPrice ( ) , $ priceValue ) ; } $ itemPrice = $ priceValue * $ item -> getCalcQuantity ( ) ; // calculate items discount $ discount = ( $ itemPrice / 100 ) * $ item -> getCalcDiscount ( ) ; // calculate total item price $ totalPrice = $ itemPrice - $ discount ; return $ totalPrice ; }
Calculates the overall total price of an item

@param CalculableBulkPriceItemInterface $item
@param string|null $currency
@param bool|null $useProductsPrice

@return int
@throws PriceCalculationException
Calculates the overall total price of an item