PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] How to add a common text after the price in magento 2

 August 23, 2022     magento, magento2     No comments   

Issue

Hi I want to add "VAT excl " text after the product price in single product page . How can i do this . Which file i need to edit . Please suggest the correct path

app/design/frontend/mythemes/default/Magento_Catalog/templates/

Solution

Method - 1: If you want to display custom text only in product view page, then create catalog_product_view.xml in your custom theme

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>

Now create customtext.phtml and add your custom text

app/design/frontend/Vendor/theme/Magento_Catalog/templates/view/customtext.phtml

Now flush the cache and check

Method - 2: If you want to display custom text after price at everywhere then override final_price.phtml

FROM

vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

TO

app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/price/final_price.phtml

Method - 3: Last and the most simple way to do it with CSS

 .product-info-price .price:after {
    content: 'Custom Text';
}


Answered By - Jinesh
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing