如何在 magento 2 的价格后添加通用文本
How to add a common text after the price in magento 2
您好,我想在单个产品页面的产品价格后添加 "VAT excl " 文本。我怎样才能做到这一点 。我需要编辑哪个文件。请建议正确的路径
app/design/frontend/mythemes/default/Magento_Catalog/templates/
方法 - 1:如果您只想在产品视图页面显示自定义文本,则在您的自定义主题中创建catalog_product_view.xml
app/design/frontend/Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<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>
</body>
</page>
现在创建 customtext.phtml 并添加您的自定义文本
app/design/frontend/Vendor/theme/Magento_Catalog/templates/view/customtext.phtml
现在刷新缓存并检查
方法 - 2:如果你想在任何地方显示价格后的自定义文本,那么覆盖 final_price.phtml
来自
vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml
到
app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/price/final_price.phtml
方法三:最后也是最简单的方法 CSS
.product-info-price .price:after {
content: 'Custom Text';
}
您好,我想在单个产品页面的产品价格后添加 "VAT excl " 文本。我怎样才能做到这一点 。我需要编辑哪个文件。请建议正确的路径
app/design/frontend/mythemes/default/Magento_Catalog/templates/
方法 - 1:如果您只想在产品视图页面显示自定义文本,则在您的自定义主题中创建catalog_product_view.xml
app/design/frontend/Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<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>
</body>
</page>
现在创建 customtext.phtml 并添加您的自定义文本
app/design/frontend/Vendor/theme/Magento_Catalog/templates/view/customtext.phtml
现在刷新缓存并检查
方法 - 2:如果你想在任何地方显示价格后的自定义文本,那么覆盖 final_price.phtml
来自
vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml
到
app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/price/final_price.phtml
方法三:最后也是最简单的方法 CSS
.product-info-price .price:after {
content: 'Custom Text';
}