I don't know how to implement this task.This is my task screenshot.Please check my screenshot.
Any help will be appreciated.
add following code will give percentage saving
<?php
$_finalPrice =$_product->getFinalPrice();
$_price =$_product->getPrice();
if($_finalPrice < $_price):
$_savingPercent = 100 - round(($_finalPrice / $_price)*100);
echo $_savingPercent; ?> % Off
?>
<?php endif; ?>
If you want to add it on final_price.phtml
<?php
$_finalPrice =$block->getSaleableItem()->getFinalPrice();
$_price =$block->getSaleableItem()->getPrice();
if($_finalPrice < $_price):
$_savingPercent = 100 - round(($_finalPrice / $_price)*100);
echo $_savingPercent; ?> % Off
?>
<?php endif; ?>
could you pls advice which is correct place to add your piece of code?
I'm a bit confused because it has no php opening block like <?php if
but have closing one...