如何在自定義主題中為模塊覆蓋html?


1

自定義Braintree付款方式的正確方法是-為付款卡添加圖片?如何在自定義主題中覆蓋模塊腦樹HTML?

我試圖從

複製form.html
vendor/magento/module-braintree/view/frontend/web/template/payment/form.html

對其進行自定義並粘貼到:

app/design/frontend/MJ/theme/Magento_Braintree/web/template/

也在這裡嘗試過:

app/design/frontend/MJ/theme/Magento_Braintree/templates/html/

,但是本機顯示(我使用了不同的類名來令人討厭的文件)。因此,我認為我的結構錯誤。

我的目標是添加諸如Visa和PayPal之類的付款方式圖片,以顯示在"信用卡"選項下。我通過編輯此文件來做到這一點:

vendor/magento/module-braintree/view/frontend/web/template/payment/form.html

添加此代碼:

    <span class="field type">
        <span class="control">
            <ul class="credit-card-types amir-credit-card-types">
                <!-- ko foreach: {data: getCcAvailableTypes(), as: 'item'} -->
                <li class="item  item._active _active"  >
                    <!--ko if: $parent.getIcons(item) -->
                    <img class="" data-bind="attr: {
                            'src': $parent.getIcons(item).url,
                            'width': $parent.getIcons(item).width,
                            'height': $parent.getIcons(item).height
                        }">
                    <!--/ko-->
                </li>
                <!--/ko-->
            </ul>
        </span>
    </span>

我的目標得以實現:

enter image description here

現在我的問題是,如何在自定義主題中覆蓋module-braintree

我不確定如何構造文件夾或將form.html放置在何處:

enter image description here

2

The correct path is:

app/design/frontend/MJ/theme/Magento_Braintree/web/template/form.html

Delete all the other files and make sure you’ve deployed static content. Depending on the version of Magento 2 and your deployment mode, that might be what’s causing the issue.

Go to pub/static/{your file path} and check if the file exists. It will only work when the file exists at the above mentioned path.

Update

Copy

vendor/magento/module-braintree/view/frontend/web/template/payment/form.html

To

app/design/frontend/MJ/theme/Magento_Braintree/web/template/payment/form.html