If I copy the file default.phtml from design/frontend/base/default/template/checkout/total/ to my theme folder (design/frontend/my_package/my_theme/template/checkout/total/default.phtml) everything is fine, my changes are applied and I can see them on the front end. But what I want to do is different. I need this default.phtml file to be in a module that can be easily switched off when not needed; to achieve this I need to override the template file but here I got stuck because I couldn't find any reference to this template in checkout.xml

I also tried to modify the renderTotal() function in Mage/Checkout/Block/Cart/Totals.php (I copied the file in my module, didn't altered the core files) and I was able to apply some changes (I needed a colspan=2 instead of 1) but not all of them (the second cell is still being displayed when the colspan is set to 2 while I want only the cell with the colspan=2 to be shown). So the only way I can achieve what I need is to modify the default.phtml file.

So my question is: how can i override the dedault.phtml?

1 Answer 1


The template is set in app/code/core/Mage/Checkout/Block/Total/Default.php. That's why you have to modify directly this file or to copy it in app/code/local and then to modify it or to overwrite it in your own custom module:




class Namespace_Modulename_Block_Total_Default extends Mage_Checkout_Block_Total_Default
    protected $_template = 'checkout/total/your_default.phtml';
    protected $_store;

    protected function _construct()
        $this->_store = Mage::app()->getStore();

I didn't test it but it should be working. :)

  • Sorry, I was trying to answer and I post it before finishing it.
    – lounik
    Commented Jan 1, 2015 at 19:17
  • I tried your method but if I try to have my template default.phtml in a subfolder inside the template folder (something like $_template = 'my_subfolder/checkout/total/my_default.phtml';), then my_default.phtml is no longer used and the frontend use magento phtml file
    – lounik
    Commented Jan 1, 2015 at 19:20
  • If you make your custom module, it's recommended to put the template files in app/design/frontend/base/default/template. Then the structure (and names of the dirs/files) doesn't matter (it's recommended to be namespace/modulename/...) but it will work each way. If your file is app/design/frontend/base/default/template/my_subfolder/checkout/total/my_default.phtml and $_template = 'my_subfolder/checkout/total/my_default.phtml'; - it should be working fine. In one word - there is no difference in how many subdirectories is the file. So if you make it right - please try to flush the cache.
    – michael
    Commented Jan 1, 2015 at 20:13
  • Unfortunately it doesn't work, it shows the 'frontend/base/default/template/checkout/total/default.phtml' instead of my_default.phtml in frontend/base/default/template/my_subfolder/checkout/total
    – lounik
    Commented Jan 2, 2015 at 7:18
  • Now I researched the code more deeply. I tested my code and it's working. But this class Mage_Checkout_Block_Total_Default and this template checkout/total/default.phtml are only called in app/code/core/Mage/Checkout/Block/Cart/Totals.php -> function _getTotalRenderer and if it doesn't have $config which on a standard Magento installation has never happened. So are you sure that you want to rewrite this template? Please enable template path hints and block path hints and check for sure which are the files.
    – michael
    Commented Jan 2, 2015 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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