1

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

0

try to set it also for

vendor/magento/module-configurable-product/view/frontend/templates/product/view/type/options/configurable.phtml 
  • Not Working.. Here is the code that we used – Developer Account Aug 9 '18 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, privacy policy and cookie policy

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