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