{"id":2067,"date":"2022-09-19T07:30:25","date_gmt":"2022-09-19T07:30:25","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/how-to-use-a-custom-price-template-in-magento-2\/"},"modified":"2025-09-01T11:26:53","modified_gmt":"2025-09-01T05:56:53","slug":"how-to-use-a-custom-price-template-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/how-to-use-a-custom-price-template-in-magento-2\/","title":{"rendered":"How to Use a Custom Price Template in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello Magento buddies  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I am back with another blog post on&nbsp;<em><strong>how to use a custom price template in Magento 2<\/strong><\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/business.adobe.com\/products\/magento\/magento-commerce.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento<\/a>&nbsp;is incredibly impressive eCommerce platform, isn\u2019t it? It allows high-end&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-development-services.html\" target=\"_blank\" rel=\"noreferrer noopener\">customization<\/a>&nbsp;and the creation of storefronts, as we imagine. It truly empowers the store owners to tweak every minute details of the storefront including the price tag shown on various pages. As an enthusiastic store owner, you may want to use a custom price template in Magento 2 and change the look of the price tag to better match your&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/best-magento-2-themes\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento store\u2019s theme<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Recently, I came across one such requirement of customizing the price template in Magento 2 for one of our clients and found the solution. In this blog post, I will share with you the complete solution to using a custom price template in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Methods to Use Custom Price Template in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To use a custom price template in Magento 2, we need to override the final_price.phtml file in Magento 2 with the custom template. It can be done in two ways:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Override Template File Directly in Theme<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Change Template File in Custom Extension<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Override Template File Directly in Theme<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can change the final_price.phtml directly in the vendor folder of the Magento source code. But, directly tweaking the source code of the Magento 2 is not advisable at all. Also, the changes can get reverted back in case of a\u00a0<a href=\"https:\/\/meetanshi.com\/magento-upgrade-service.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento version upgrade<\/a>. In order to prevent such reversal, it is advisable to override the template fine in the vendor folder by that in the theme.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Override the following path of the price template:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vendormagentomodule-catalogviewbasetemplatesproductpricefinal_price.phtml<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>with<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>appdesignfrontend&lt;theme_package&gt;Magento_Catalogtemplatesproductpricefinal_price.phtml<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Change Template File in Custom Extension<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using a custom extension that tweaks the pricing layout in Magento 2; you can create a custom module to override the price layout file in Magento 2. Follow the below steps if you want to use a custom price template in Magento 2 using a custom extension.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1:<\/strong>&nbsp;Create&nbsp;<strong>app\/code\/Vendor\/Extension\/etc\/di.xml&nbsp;<\/strong>with the following code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">\n    &lt;type name=\"Magento\\Catalog\\Pricing\\Render\\FinalPriceBox\">\n        &lt;plugin name=\"override_price_block\" type=\"Vendor\\Extension\\Plugin\\FinalPricePlugin\" \/>\n&lt;\/type>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2:<\/strong>&nbsp;Create&nbsp;<strong>app\/code\/Vendor\/Extension\/Plugin\/FinalPricePlugin.php<\/strong>&nbsp;with the following code:<br><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nnamespace Vendor\\Extension\\Plugin;\n \nclass FinalPricePlugin\n{\n    public function beforeSetTemplate(\\Magento\\Catalog\\Pricing\\Render\\FinalPriceBox $subject, $template)\n    {\n        if ($template == 'Magento_Catalog::product\/price\/final_price.phtml') {\n           return ['Vendor_Extension::product\/price\/final_price.phtml'];\n        } \n        else\n        {\n            return [$template];\n        }\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3:<\/strong>&nbsp;Create&nbsp;<em><strong>final_price.<\/strong><strong>phtml<\/strong><\/em>&nbsp;file at&nbsp;<strong>app\/code\/Vendor\/Extension\/view\/frontend\/templates\/product\/price\/&nbsp;<\/strong>and add your desired code for the price layout template.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do share the solution with the Magento community via social media.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Magento buddies I am back with another blog post on&nbsp;how to use a custom price template in Magento 2. Magento&nbsp;is incredibly impressive eCommerce platform,&#8230;<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2067","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2067"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2067\/revisions"}],"predecessor-version":[{"id":21339,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2067\/revisions\/21339"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}