Magento translate renderTotals()

Posted by & filed under Magento, PHP.

I had an issue where Magento was not picking up translation of “Free Shipping – Free” on my Checkout page. I got round this by adding a function inside /app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php inside the collect() function:

        if ($method) {
	    
	    function mof($txt){
		$expr = new Mage_Core_Model_Translate_Expr($txt, 'Mage_Page');
		$args = array($txt, $expr);
		return Mage::app()->getTranslator()->translate($args);
	    }
	    
            foreach ($address->getAllShippingRates() as $rate) {
                if ($rate->getCode()==$method) {
                    $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
                    $this->_setAmount($amountPrice);
                    $this->_setBaseAmount($rate->getPrice());
		    
                    $shippingDescription = mof($rate->getCarrierTitle()) . ' - ' . mof($rate->getMethodTitle());
		    
                    $address->setShippingDescription(trim($shippingDescription, ' -'));
                    break;
                }
            }
        }

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Bitnami