0

I wanted to show you save percentage in product detail page for simple and configurable both.

I have added code in default.phtml file location

Theme/Magento_Catalog/templates/product/view/type/default.phtml.

<?php

if($_product->getTypeId() == "simple") {
   $simplePrice = $_product->getPrice();
} else {
   $_children = $_product->getTypeInstance()->getUsedProducts($_product);
    foreach ($_children as $child){
    $simplePrice = $child->getPrice();
    break;
   }
}

$_finalPrice =$_product->getFinalPrice();
$_price = $simplePrice;
if($_finalPrice < $_price) {
   $_savingPercent = 100 - round(($_finalPrice / $_price)*100);
   **echo 'Your save '.$_savingPercent . '%';**

}
?>
2
  • Is it working for you or please ask your question – Gideon Babu Jun 23 '18 at 12:59
  • Specify the issue you are facing into details? – Dhiren Vasoya Jun 23 '18 at 12:59

Your Answer

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

Browse other questions tagged or ask your own question.