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