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