6

I want to add static text above the price. I tried to add as explained in the thread (Magento 2: How to add text within container via XML) but it didn't work for me.

<referenceContainer name="product.info.main">
    <block class="Magento\Catalog\Pricing\Render" name="product.price.final" before="product.price.tier">
        <arguments>
            <argument translate="true" name="text" xsi:type="string">Mytext</argument>
            <argument name="price_render" xsi:type="string">product.price.render.default</argument>
            <argument name="price_type_code" xsi:type="string">final_price</argument>
            <argument name="zone" xsi:type="string">item_view</argument>
        </arguments>
    </block>
</referenceContainer>
  • have you tried <action> tag ? – Manthan Dave Jan 31 '17 at 9:04
  • yes but that also doesnt work. – Jai Jan 31 '17 at 9:18
2

This would add your static text block above the price.

<referenceContainer name="product.info.main">
    <block class="Magento\Framework\View\Element\Text" name="your.block.name" before="product.info.price">
        <arguments>
            <argument name="text" xsi:type="string"><![CDATA[<div>Content of your block.</div>]]></argument>
        </arguments>
    </block>
</referenceContainer>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.