1

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.

1
  • please let me know if i have use custom module then how override? Aug 2, 2017 at 7:14

3 Answers 3

15

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
1
  • 1
    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, 2019 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

2

You were so close yourself to the best answer:

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

Please accept this answer, because rewriting template in design catalog might not be the best solution, especially if you trying to add new functionality via your own module (which is recommended way of tweaking Magento to your needs).

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.