2

I have done some research to this subject but couldn't seem to find a detailed answer.

What I need

To overwrite a template file from a third party module in my case: Amasty One Step Checkout

Template file to overwrite:

/app/code/Amasty/Checkout/view/frontend/web/template/onepage/shipping/methods.html

I have found that this file is loaded using knockoutjs via this function:

<!-- ko with: requestComponent('checkout.steps.shipping-step.shippingAddress') -->
<!-- ko template: 'Amasty_Checkout/onepage/shipping/methods' --><!-- /ko -->
<!--/ko-->

in file:

app\code\Amasty\Checkout\view\frontend\web\template\onepage3円columns.html

What I've done

Added module dependency

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
 <module name="Plugin_Name" setup_version="1.0.0">
 <sequence>
 <module name="Magento_Checkout" />
 <module name="Amasty_Checkout" />
 </sequence>
 </module>
</config>

Tried overwriting the template file like this in my module's checkout_index_index.xml

<referenceBlock name="checkout.steps.shipping-step.shippingAddress">
 <action method="setTemplate">
 <argument name="template" xsi:type="string">Plugin_Name::shipping_view.html</argument>
 </action>
</referenceBlock>

But without success..

Can someone explain what steps to take to overwrite a third party's template file and if there is a difference if it is loaded in another template file via knockoutjs

Thanks in advance

asked Jun 14, 2018 at 20:20

1 Answer 1

3

Try this:

Create requirejs-config.js file at below path.

/app/code/Vendor/Module/view/frontend/requirejs-config.js

And put below code in requirejs-config.js

var config = {
 map: {
 '*': {
 'Amasty_Checkout/template/onepage/shipping/methods.html': 
 'Vendor_Module/template/onepage/shipping/methods.html'
 }
 }
};

We can override any html file in this way.

answered Jun 14, 2018 at 21:01
1
  • What if we want to override a design template file to a custom module? Commented Sep 16, 2019 at 11:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.