0

I have added the following code in /public_html/vendor/magento/module-configurable-product/view/base/templates/product/price/final_price.phtml

   <?php if ( $block->hasSpecialPrice()): ?>
<span class="old-price sly-old-price">
    <?php /* @escapeNotVerified */ echo $block->renderAmount($priceModel->getAmount(), [
        'display_label'     => __('Regular Price'),
        'price_id'          => $block->getPriceId('old-price-' . $idSuffix),
        'price_type'        => 'oldPrice',
        'include_container' => true,
        'skip_adjustments'  => true
    ]); ?>
</span>
 <span class="saving-price"><span class="saving-text"></span>
  <?php
  $wasPrice = $priceModel->getValue();
 $nowPrice = $finalPriceModel->getValue();
  $saving = $wasPrice - $nowPrice; 
  $savingpct = number_format((float)(100*(($wasPrice - 
  $nowPrice)/$wasPrice)), 0);
   if ($nowPrice < $wasPrice){
   echo $savingpct. "% Off";
   }
  ?>
 </span>
 <?php  endif; ?>

Its showing % discount but on changing variation the % discount is not changing its same as first product %

How to change the % discount on changing variations

Ex if configurable options have 3 simple products A,B and C

If A has 10% discount,B has 20% discount and C has 30% discount

Its showing only 10% for all products on change

how to fix the issue

  • You need to use knockout JS for that. – Mohit Kumar Arora May 15 at 13:29
  • directly editing Magento core file is not recommended – fmsthird May 15 at 15:01

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.