2

I have tried to override this template file by overriding the whole block where its called i.e Magento\Payment\Block\Info

But i am not able to override this file Magento_Payment::info/default.phtml

Is their any way we can override this file ?

4
  • Did you try to override this file in your theme ? app/design/frontend/Vendor/themeName/Magento_Payment/templates/info/default.phtml?
    – SebastianT
    Mar 16, 2021 at 11:29
  • I am not using theme so can't do it in theme.
    – devhs
    Mar 16, 2021 at 11:30
  • Did you use preference to override this block class?
    – SebastianT
    Mar 16, 2021 at 14:27
  • 1
    Thanks for the suggestions, i have added answer which is working.
    – devhs
    Mar 17, 2021 at 4:47

1 Answer 1

1

di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Payment\Block\Info">
        <plugin name="module_paympent_view_override_template" type="Vendor\Module\Plugin\Payment\Block\Info" />
    </type>
</config>

Info.php

<?php
namespace Vendor\Module\Plugin\Payment\Block;
 
class Info
{
    public function beforeToHtml(\Magento\Payment\Block\Info $subject)
    {        
            $subject->setTemplate('Vendor_Module::info/default.phtml');        
    }
}
0

Your Answer

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

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