首页 > 解决方案 > 我们如何在magento2的产品页面上的产品原价后添加“包含所有税费”标签?

问题描述

请帮助我如何在magento2平台的产品页面上显示原始产品价格后的标签“包含所有税费”?

并且让我知道我可以轻松添加 HTML 代码以显示相同的文件结构。

请参阅屏幕截图以供参考:https ://prnt.sc/10hqx9e

<div class="product-info-price"><div class="price-box price-final_price" data-role="" data-product-id="" data-price-box=""><span class="label-taxes"><label>Inclusive of all taxes</label></span></div></div>

上面的代码只是一个虚拟代码,但我使用了产品页面的magneto2的默认div结构。

请帮忙!

提前致谢。

标签: phphtmllabelmagento2magento2.2

解决方案


首先,如果您只想在产品视图页面中显示自定义文本,则在路径 app/design/frontend/Your-theme/theme/Magento_Catalog/layout/catalog_product_view.xml 的自定义主题中创建 catalog_product_view.xml

添加此代码

<referenceContainer name="product.info.main">
    <block class="Magento\Framework\View\Element\Template" name="custom.text" template="Magento_Catalog::view/customtext.phtml" after="product.info.price"/>
</referenceContainer>

现在在路径 app/design/frontend/Your-theme/theme/Magento_Catalog/templates/view/customtext.phtml 上创建 customtext.phtml 文件

添加以下代码

<div class="product-info-price">
    <div class="price-box price-final_price">
        <span class="label-taxes">
            <label><?php echo __("Inclusive of all taxes") ?></label>
        </span>
    </div>
</div>

不要忘记清除缓存:)


推荐阅读