Get Price For Configurable Product Magento 2

 if you try getFinalPrice(); for simple product it will be same results with getSpecialPrice(); that reason I m checking type.

<span class="onsale">
<span>
<?php
    //echo $_product->getTypeId();
    if($_product->getTypeId()!="simple"){
        $label_price=$_product->getSpecialPrice();
        $final_price=$_product->getFinalPrice();
        $save_percent = 100 - round(($final_price / $label_price)*100);
        echo $save_percent.'% Off';
    }else{

        $label_price=$_product->getPrice();
        $final_price=$_product->getSpecialPrice();
        $save_percent = 100 - round(($final_price / $label_price)*100);
        echo $save_percent.'% Off';

    }
    ?>
</span>
</span>

Leave a comment

Your email address will not be published. Required fields are marked *