I have created a custom shipping module following the below two tutorials
http://techportal.inviqa.com/2011/06/09/creating-a-custom-magento-shipping-method/
I now need to translate the shipping method title, however, I am getting the following error
Invalid method VMR_Shipping_Model_Carrier_Customrate::__(Array
(
[0] => Flat Rate: 3-10 Days
)
)
using this line of code
$optionTitle = $this->__('Flat Rate: 3-10 Days');
Any ideas or input is greatly appreciated!!
This is because the
__()function is defined in the abstract classes of core block, core controller and core helper, but not core models. You can easily translate anything you wish by setting up a helper that extendsMage_Core_Helper_Abstractand run that function.echo Mage::helper('vrm_shipping')->__('Flat Rate: 3-10 Days')… or if you’re feeling lazy, just get the abstract helper to translate for you
echo Mage::helper('core')->__('Flat Rate: 3-10 Days')…However, I’m not sure the specifics of what you’re doing, but generally it is best practice to translate within the block or templates themselves. Why don’t you call the
__()function in the template that outputs the shipping methods instead?