0

Here is my catalog_product_view.xml: I want to insert one CustomBlock to this final price block, so i can use getChildHtml() to call in template final_price.phtml, but it does not work so far, why ?

 <referenceBlock name="product.price.final">
        <block class="Magento\Framework\View\Element\Template" name="custom.block"  template="CustomModule::custom.phtml"/>
    </referenceBlock>
2
  • I think adding the custom block to the "product.info.price" block is better.
    – Aaron Wang
    Commented Sep 16, 2022 at 17:35
  • @WangGang I have tried "product.info.price", it still does not work. Commented Sep 16, 2022 at 18:52

2 Answers 2

0
<referenceBlock name="product.info.price">
        <block class="Magento\Framework\View\Element\Template" name="custom.block"  template="CustomModule::custom.phtml" after="product.price.final" />
    </referenceBlock>
1
  • Sorry, this is not what I asked. I need to inject my template below 'old-price' element in final_price.phtml. I noticed the normal XML method does not work as expected, so I would like to know how price rendered in Magento and how to deal with it. Commented Sep 17, 2022 at 17:55
0

Please try using view model for same

1
  • Can you give me one example ? Or point me which file in magento is using view model ? Thanks ! Commented Oct 4, 2022 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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