1

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?

Thanks

4
$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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.