getAllItems() as $item) { if (!$item->getHasChildren()){ $baseInvoiceTotalCost += $item->getBaseCost()*$item->getQty(); } } $invoice->setBaseCost($baseInvoiceTotalCost); return $this; } }