在 Magento 中向运输方式添加自定义徽标

问题描述 投票:0回答:1

¿如何将自定义徽标添加到 Magento 中的运输方式?我需要在结账过程中为每种运输方式显示特定的徽标。实现这一目标的最佳方法是什么?我应该在 Magento 中哪里进行代码修改?

magento2
1个回答
0
投票

这主要是 CSS 和淘汰 html 工作。 使用具有自定义属性匹配的 CSS 选择器。

模板的原始实现是在knockout模板中

vendor/magento/module-checkout/view/frontend/web/template/shipping-address/shipping-method-item.html
  1. 用您的主题覆盖 html,添加
    attr
    属性。
    attr
    是knockout属性,用于更新节点属性。
<tr class="row"
    click="element.selectShippingMethod"
    attr="'data-carrier-code': method.carrier_code">
  1. 在 CSS 中使用
    tr.row[data-carrier-code="my_super_carrier"]
    或类似内容。
  2. 使用 CSS 背景、内边距、边距将内容组合在一起。

祝你好运

© www.soinside.com 2019 - 2024. All rights reserved.