*/ class Mage_XmlConnect_Block_Cart_CartTotals extends Mage_Checkout_Block_Cart_Totals { /** * Default totals renderer * * @var string */ protected $_defaultRenderer = 'xmlconnect/cart_cartTotals_default'; /** * Render cart totals xml * * @return Mage_XmlConnect_Model_Simplexml_Element */ protected function _toHtml() { /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */ $cartXmlObject = $this->getCartXmlObject(); /** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */ $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); foreach($this->getTotals() as $total) { $code = $total->getCode(); if ($total->getAs()) { $code = $total->getAs(); } $isNode = Mage::getConfig()->getNode("global/xmlconnect/sales/quote/totals/{$code}/is_node"); if ($isNode) { $this->_getTotalRenderer($code)->setTotal($total)->setCartObject($cartXmlObject)->toHtml(); } else { $this->_getTotalRenderer($code)->setTotal($total)->setCartObject($totalsXmlObj)->toHtml(); } } $cartXmlObject->appendChild($totalsXmlObj); return $this; } /** * Get renderer block * * @param string $code * @return Mage_Core_Block_Abstract */ protected function _getTotalRenderer($code) { $blockName = $code . '_total_renderer'; $block = $this->getLayout()->getBlock($blockName); if (!$block) { $block = $this->_defaultRenderer; $config = Mage::getConfig()->getNode("global/xmlconnect/sales/quote/totals/{$code}/renderer"); if ($config) { $block = (string) $config; } $block = $this->getLayout()->createBlock($block, $blockName); } /** * Transfer totals to renderer */ $block->setTotals($this->getTotals()); return $block; } }