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

1 Answer 1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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