How to override magento function?

How to override magento function? – Stack Overflow

I have added prefix and telephone field on customer registration page and want to use that value in checkout billing address

So , I have to override magento \app\code\core\Mage\Checkout\Block\Onepage\Billing.php for customer selected prefix and telephone.

I want your help to override this particular functions in local

public function getPrefix() { … }

Please help me …

share|improve this question
 
   
feedback

3 Answers

Just extends Mage_Checkout_Block_Onepage_Billing class, and do one public function getPrefix() with the same sign.

Magento do the rest.

share|improve this answer
 
   
feedback

create the folder mage into your app\code\local folder as

\app\code\local\Mage\Checkout\Block\Onepage\Billing.php

and just put the function getPrefix() inside the Billing.php with your modification that will works here

share|improve this answer
 
   
feedback

1) Edit your Config.xml file in your module

<global>
   <blocks>
      <checkout>
        <rewrite>
            <onepage_billing>Namespace_ModuleName_Block_Onepage_Billing</onepage_billing>
        </rewrite>
     </checkout>
   </blocks>
</global>

2) create Billing.php file in namespace/Module/Block/Onepage/Billing.php

class Namespace_ModuleName_Block_Onepage_Billing extends Mage_Checkout_Block_Onepage_Billing
{

    getPrefix() { ... }

}
share|improve this answer