0

I want to override Magento 2 html template located at

vendor/magento/module-checkout/view/frontend/web/template/billing-address/details.html

I tried using require-config.js for frontend like this:

var config = { 
    map: {
       '*': {
         'Magento_Checkout/template/billing-address/details':
             'Namespace_Module/template/billing-address/details'
    }
  }
};

and I put that file at

Namespace/Module/view/frontend/template/billing-address/details.html

But I got the following error:

Unable to resolve the source file for 'frontend/Vendor/vendor_theme/en_US/Namespace_Module/template/billing-address/details.html' #0 /var/www/rotoki/vendor/magento/framework/App/StaticResource.php(97)

I think Magento is trying to find that file inside my theme folder instead of my module folder.

  • please let me know if i have use custom module then how override? – Magento2 Devloper Aug 2 '17 at 7:14
6

Just copy file from

vendor/magento/module-checkout/view/frontend/web/template/billing-address/details.html

And put it to

app/design/frontend/Vendor/YourTheme/Magento_Checkout/web/template/billing-address/details.html

Run below commads for deploy static content

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
  • Thanks, I had seen advice elsewhere that leaves out the '/web/' part of the path in the custom theme. Putting 'template' folder in 'web' made the override work 👍 – 00-BBB Aug 30 at 9:41
3

You should give first priority to custom module for override html template files and give second priority to custom theme

To override html file with a custom theme you need not require-config.js.

As you question you use custom module to override html files that's good.

Check your path you need to copy in details.html at

app/code/Vendor/Module/view/frontend/web/template/billing-address/details.html

After flush cache and refresh page, details.html is created or copied in pub/static folder at

pub/static/frontend/cendor/theme/en_US(Language)/Magento_Checkout/template/billing-address/details.html

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.