{"id":1457,"date":"2020-12-12T10:53:18","date_gmt":"2020-12-12T10:53:18","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/display-percentage-of-discount-on-product-list-and-view-page-in-magento-2\/"},"modified":"2025-07-17T10:17:21","modified_gmt":"2025-07-17T04:47:21","slug":"display-percentage-of-discount-on-product-list-and-view-page-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/display-percentage-of-discount-on-product-list-and-view-page-in-magento-2\/","title":{"rendered":"How to Display Percentage of Discount on Product List and View Page in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/meetanshi.com\/blog\/offering-discounts-to-customers-in-e-commerce\/\" target=\"_blank\" rel=\"noreferrer noopener\">Discounts<\/a>&nbsp;have been the most effective tool to beat the competition, attract potential customers, and generate sales for ages!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Offering attractive deals to the customers is surely going to increase the conversion rate.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, it is equally important to tactfully present your offers to the customers in a way that will lure them to make a purchase.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Magento 2 store owners, it is going to be easy with the solution given below to display percentage discount on the product page and category page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Showing the percentage value of discount along with the original price and special price that the default\u00a0Magento 2\u00a0displays will push the potential customer to avail the deal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the programmatic solution to&nbsp;<em><strong>display percentage of discount on product list and view page in Magento 2<\/strong><\/em>&nbsp;below:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Display Percentage of Discount on Product List and View Page in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/meetanshi.com\/blog\/override-extension-file-in-theme-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">Override the below file in your theme<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Magento_Catalog::product\/price\/final_price.phtml<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and put the below code in the file.<\/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 \/** @var \\Magento\\Catalog\\Pricing\\Render\\FinalPriceBox $block *\/ \/** ex: \\Magento\\Catalog\\Pricing\\Price\\RegularPrice *\/ \/** @var \\Magento\\Framework\\Pricing\\Price\\PriceInterface $priceModel *\/ $priceModel = $block->getPriceType('regular_price'); \/** ex: \\Magento\\Catalog\\Pricing\\Price\\FinalPrice *\/ \/** @var \\Magento\\Framework\\Pricing\\Price\\PriceInterface $finalPriceModel *\/ $finalPriceModel = $block->getPriceType('final_price'); $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : ''; $schema = ($block->getZone() == 'item_view') ? true : false; $fprice=($finalPriceModel->getAmount()->getValue()); $rprice=$priceModel->getAmount()->getValue(); $discount = 100 - round(($fprice \/ $rprice) * 100); ?-->\n&lt;!--?php if ($block->hasSpecialPrice()) :?-->\n    \n        &lt;!--?= \/* @noEscape *\/ $block->renderAmount($finalPriceModel->getAmount(), [ 'display_label' => __('Special Price'), 'price_id' => $block->getPriceId('product-price-' . $idSuffix), 'price_type' => 'finalPrice', 'include_container' => true, 'schema' => $schema ]); ?-->\n    \n    &lt;!--?= $discount.\"% Discount\";?-->\n    \n        &lt;!--?= \/* @noEscape *\/ $block->renderAmount($priceModel->getAmount(), [ 'display_label' => __(' '), 'price_id' => $block->getPriceId('old-price-' . $idSuffix), 'price_type' => 'oldPrice', 'include_container' => true, 'skip_adjustments' => true ]); ?-->\n    \n&lt;!--?php else :?-->\n    &lt;!--?= \/* @noEscape *\/ $block->renderAmount($finalPriceModel->getAmount(), [ 'price_id' => $block->getPriceId('product-price-' . $idSuffix), 'price_type' => 'finalPrice', 'include_container' => true, 'schema' => $schema ]); ?-->\n&lt;!--?php endif; ?-->\n&lt;!--?php if ($block->showMinimalPrice()) :?-->\n    &lt;!--?php if ($block->getUseLinkForAsLowAs()) :?-->\n        \n            &lt;!--?= \/* @noEscape *\/ $block->renderAmountMinimal() ?-->\n        \n    &lt;!--?php else :?-->\n        \n            &lt;!--?= \/* @noEscape *\/ $block->renderAmountMinimal() ?-->\n        \n    &lt;!--?php endif?-->\n&lt;!--?php endif; ?--><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also read:&nbsp;<\/strong><a href=\"https:\/\/meetanshi.com\/blog\/setup-discount-with-minimum-purchase-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Setup Discount with Minimum Purchase in Magento 2<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do share the post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Discounts&nbsp;have been the most effective tool to beat the competition, attract potential customers, and generate sales for ages! Offering attractive deals to the customers is surely going to increase the conversion rate. However, it is equally important to tactfully present your offers to the customers in a way that will lure them to make a [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1457","post","type-post","status-publish","format-standard","hentry","category-magento"],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1457","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\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1457"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1457\/revisions"}],"predecessor-version":[{"id":14578,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1457\/revisions\/14578"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}