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