Skip to content

How to override taxvat.phtml

Hi dears I want to override taxvat.phtml in vendor > magento > module-customer > view > frontend > templates > widget

Before I try to create a file Vendor > Module > etc > di.xml with this code :

<type name="MagentoCustomerBlockWidgetName">
    <plugin name="vatcode" type="VendorModulePluginCustomerBlockWidgetTaxvat"/>
</type>

and in Taxvat code :

namespace VendorModulePluginCustomerBlockWidget;

use MagentoCustomerBlockWidgetTaxvat as Taxobj;

class Taxvat
{

    public function after_construct(Taxobj $result)
    {
        $result->setTemplate('Vendor_Module::widget/taxvat.phtml');
        return $result;
    }

}

after run but i have below error :

Type Error occurred when creating object: MagentoCustomerBlockWidgetNameInterceptor, Argument 1 passed to VendorModulePluginCustomerBlockWidgetTaxvat::after_construct() must be an instance of MagentoCustomerBlockWidgetTaxvat, instance of MagentoCustomerBlockWidgetNameInterceptor given, called in /public_html/vendor/magento/framework/Interception/Interceptor.php on line 146