php - 我们如何在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结构。
请帮忙!
提前致谢。
解决方案
首先,如果您只想在产品视图页面中显示自定义文本,则在路径 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>
不要忘记清除缓存:)
推荐阅读
- mysql - 将 JSON customers_contacts 添加到客户表中
- python - 无法使用 Ride-Robot-SSH 库执行命令
- python - 如何在 python 数据框中找到唯一的列表条目?
- terraform - 使用 Terraform 在 EC2 Windows 实例中初始化 EBS 卷
- jquery - 数据表保存手动输入的值
- google-cloud-platform - 如何为 Visual Studio ion Visual Studio 2019 社区安装谷歌云工具?
- angular - 在 form.reset 之后使用默认输入重新填充表单控件
- python - 合并连续列中相同变量的级别
- javascript - 如何仅在文件上传并检查条款和条件时才激活按钮?
- kotlin - 成员函数和属性的区别