2

I have set the discount in percentage but its showing only for the simple products.Also I want to show it in the configurable products.

For the Simple Products: vendor\magento\module-catalog\view\frontend\templates\product\view\type\default.phtml

2 Answers 2

0

try to set it also for

vendor/magento/module-configurable-product/view/frontend/templates/product/view/type/options/configurable.phtml 
1
  • Not Working.. Here is the code that we used Aug 9, 2018 at 7:41
0
<?php

  $specialprice = $_product->getSpecialPrice();
    $specialPriceFromDate = $_product->getSpecialFromDate();
    $specialPriceToDate = $_product->getSpecialToDate();    
    $today = time();
    $price = $_product->getPrice();
    if($price){
        $sale = round((($price-$specialprice)/$price)*100);
    }
    if ($specialprice) {
        if ($today >= strtotime($specialPriceFromDate) && $today <= strtotime($specialPriceToDate) || $today >= strtotime($specialPriceFromDate) && is_null($specialPriceToDate)) { ?>
            <div class="label-product label-sale">
                <span class="sale-product-icon">
                    <?php if($sale) { echo $sale.'%'; } else {echo __('Sale');} ?>
                </span>
            </div>
        <?php }
    }
?>

Your Answer

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

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