Percentage price change

i want in details product page display with $_product->getPrice() and $_product->getSpecialPrice(), also the percentage by which the price has been changed, how i can display this percentage in page?



$origPrice = $_product->getPrice();
$finalPrice = $_product->getFinalPrice();

$percentage = ($origPrice - $finalPrice) * 100 / $origPrice;

This covers both cases: when you have a special price and when you have a catalog rule that discounts your product price.
All you need to do is print the $percentage variable.
Also, do a verification if $origPrice is not zero, and format the variable value as you want.

Tags: Product / Price

Similar questions

Percentage discounts using cart price rules being calculated incorrectly
I'm running a Magento instance of 2.3.6-p1 using PHP 7.3 and having issues with Magento not calculating the discounts correctly. How I tested Below is a screenshot from the Magento admin with the incorrect values highlighted Below is a table with what I believe to be is the correct logic and highlighted cells where I believe Magento is wrong Below ...
I have added one custom attribute for product named percentage. How can I add that attribute to product price after adding that product into cart?
I have tried below code. However its working fine but other products for which custom attribute is not being added from admin, I am not able to add to cart such products.
Get a Magento product collection by special price in percentage
in my Magento shop should be a page called sale with sub pages including 10% sale, 20% sale, 30% sale … So now I need to get a product collection with all products that contain at least a special price (final price including price rule discounts would be nicer but if too difficult the special price would be enough for filtering the discounted produ...
How to change Tax percentage during checkout
We would like to change the Tax percentage on my current order during checkout. Current setup: Magento 2.1.4 Magestore OneStepCheckout Current challenge: We currently ask our customers some questions during checkout, and depending on theyre answers, they need to be given a different tax percentage (or different tax class), instead of standard 21%, ...
I want to change sticker value "Sale" to discount percentage
Is it possible in PHP to print a variable that contains string and a other variable? like : file "Lables.php" class Infortis_Ultimo_Helper_Labels extends Mage_Core_Helper_Abstract { } Actually I want to change the Sale sticker with the discount percentage. But it is not working in if condition. It gives session variable's value 0. Any suggestions? ...
What is the best way to update multiple product prices by a percentage?
We have several thousand products in our Magento store and every January we like to do a price increase of around 2-3%. In the past we have exported the products and manually edited the prices in the sheet and then uploaded the sheet. Is there a quicker way to do this?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.