Change price template only for product view page?
In catalog_product_view.xml
there is a block (product.price.render.default
) which is responsible for price rendering.
That block you can find in below paths:
/vendor/magento/module-catalog/view/adminhtml/layout/CATALOG_PRODUCT_COMPOSITE_CONFIGURE.xml
/vendor/magento/module-catalog/view/base/layout/default.xml
which is this:
<block class="Magento\Framework\Pricing\Render" name="product.price.render.default">
<arguments>
<argument name="price_render_handle" xsi:type="string">catalog_product_prices</argument>
<argument name="use_link_for_as_low_as" xsi:type="boolean">true</argument>
<!-- set "override" configuration settings here -->
</arguments>
</block>
You can copy this block to catalog_product_view.xml
inside body tag and change this
<argument name="price_render_handle" xsi:type="string">catalog_product_prices</argument>
to this
<argument name="price_render_handle" xsi:type="string">custom_catalog_product_prices</argument>
.
Then create a new xml layout file with name custom_catalog_product_prices.xml
and copy content from file /vendor/magento/module-catalog/view/base/layout/catalog_product_prices.xml
.
After copy content you can see there is so many template set in this xml layout now you can modify templates according to you in custom_catalog_product_prices.xml
file.