private function calculateTotalAmountForDeliveryExpenses(Transaction $transaction)
    {
        $total = 0;
        foreach ($transaction->getItems() as $productPurchase) {
            if($productPurchase->getProduct() instanceof Product){
                if(!$productPurchase->getProduct()->isFreeTransport()){
                    $addPercent = 0;
                    if($this->deliveryExpensesPercentage > 0) 
                        $addPercent = $productPurchase->getTotalPrice() * $this->deliveryExpensesPercentage;
                    
                    $total += $productPurchase->getTotalPrice() + $addPercent;
                }
            }else{
                $total += $productPurchase->getTotalPrice();
            }
        }
        return $total;
    }
private function calculateTotalAmountForDeliveryExpenses(Transaction $transaction)
    {
        $total = 0;
        foreach ($transaction->getItems() as $productPurchase) {
            if($productPurchase->getProduct() instanceof Product){
                if(!$productPurchase->getProduct()->isFreeTransport()){
                    $addPercent = 0;
                    if($this->deliveryExpensesPercentage > 0) 
                        $addPercent = $productPurchase->getTotalPrice() * $this->deliveryExpensesPercentage;
                    
                    $total += $productPurchase->getTotalPrice() + $addPercent;
                }
            }else{
                $total += $productPurchase->getTotalPrice();
            }
        }
        return $total;
    }
private function calculateTotalAmountForDeliveryExpenses ( Transaction $ transaction ) { $ total = 0 ; foreach ( $ transaction -> getItems ( ) as $ productPurchase ) { if ( $ productPurchase -> getProduct ( ) instanceof Product ) { if ( ! $ productPurchase -> getProduct ( ) -> isFreeTransport ( ) ) { $ addPercent = 0 ; if ( $ this -> deliveryExpensesPercentage > 0 ) $ addPercent = $ productPurchase -> getTotalPrice ( ) * $ this -> deliveryExpensesPercentage ; $ total += $ productPurchase -> getTotalPrice ( ) + $ addPercent ; } } else { $ total += $ productPurchase -> getTotalPrice ( ) ; } } return $ total ; }
Calculate total amount for delivery expenses

@param Transaction    $transaction

@return float $total
Calculate total amount for delivery expenses