I found that the BillingBlock.tpl is included in Main.tpl file and all the variables are assigned to this templates using Main.php file. I can hardcode the variable there but I am worried about if there is another core update. So I am trying to override the Main.php file from my custom extension but it's not happening.

My question is how do I override the Main.php file in civicrm from custom extension ( custom payment processor ) or if there is other method built in civicrm with which I can pass variable to Main.tpl or BillingBlock.tpl.

P.S. I followed the same directory structure as of core.

├── CRM
   └── Contribute
       └── Form
           └── Contribution
               └── Main.php

To Override Main.tpl file - you can try using Main.extra.tpl which should work

But Please try using - custom File - because if you are overriding the same file in some other extension it might not work sometime

function hook_civicrm_buildForm($formName, &$form) {
$templatePath = realpath(dirname(__FILE__)."/templates");
    'template' => "{$templatePath}/custom/custom.tpl",

and add your coding in the custom.tpl

Also please note that for billing address all the fields are hard coded in the core also same for validation -

If you need more help please let me know - thanks

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.