Magento 2 display discount percent product page
Today we discuss how in Magento 2 display discount percent product page. This topic will cover how to show % percentage saving on current product. You can use this code on any product product listing or product widget page. You can also use this code product detail page. So let’s start with our example. You need to get $_product->getFinalPrice() and $_product->getPrice() to calculate the percentage of current product.
$_finalPrice = $_product->getFinalPrice();
$_price = $_product->getPrice();
if($_finalPrice < $_price):
$_savingPercent = 100 - round(($_finalPrice / $_price)*100);
echo $_savingPercent; ?> % Off
<?php endif; ?>
$_price = $_product->getPrice();
if($_finalPrice < $_price):
$_savingPercent = 100 - round(($_finalPrice / $_price)*100);
echo $_savingPercent; ?> % Off
<?php endif; ?>
One thought on “Magento 2 display discount percent product page”
Leave a Reply
You must be logged in to post a comment.
Please share the path for both Catalog Page and Product page exact where i have to add this.
Thanks in Advance