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

4

1 Answer 1

0

Try This

Download Module: Click Here

Install module into your Magento.

Output: Click Here

Note: You must have discount rule for the products.

Your Answer

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

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