0
<?php 
if($_product->getTierPrice()){
    foreach ($tierPrice as $key => $value) {
        $qty = (int)$value['price_qty'];
        $price = $value['price'];
        $formattedTierPrice = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency(number_format($price, 2), true, false);
        $savePercentage = round(100 - ( (100 / $_product->getPrice())* $price) ) ."%";
        echo "<div style='font-weight: 600;background: #f5f5f5;padding: 5px; display: block; margin: 20px 0px 0px'>"."Buy $qty for "."<span style='color: #000;font-size: 16px;'>" . $formattedTierPrice . "</span>"." each and save ".$savePercentage."<br>"."</div>";
    }
}
?>
0
 <?php 

                        if($_product->getTierPrice()){

                            $tierPrice = $_product->getTierPrice();

                            $regular_price_of_custom = $_product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue();



                            foreach ($tierPrice as $key => $value) {



                                $regular_price_of_custom_tot = "";

                                $qty = (int)$value['price_qty']; 



                                //echo $qty."<br>" ;



                                $price = $value['price'];//echo "<br>";

                                //echo $price."<br>" ;

                                //$_product->getPrice();//echo "<br>";



                                //echo $_product->getPrice();echo "<br>";



                                $savePercentage = round(100 - ( (100 / $_product->getPrice())* $price) ) ."%";



                                //echo $savePercentage."<br>" ; // till this ok 



                                $regular_price_of_custom_tot = $regular_price_of_custom - (($regular_price_of_custom * $savePercentage) / 100);



                                //echo $regular_price_of_custom_tot."<br>" ;



                                $formattedTierPrice = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency(number_format($regular_price_of_custom_tot, 2), true, false);



                                //echo $formattedTierPrice."<hr>" ;







                                echo "<div style='font-weight: 600;background: #f5f5f5;padding: 5px; display: block; margin: 20px 0px 0px'>"."Buy $qty for "."<span style='color: #000;font-size: 16px;'>" . $formattedTierPrice . "</span>"." each and save ".$savePercentage."<br>"."</div>";

                            } 
|improve this answer|||||

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.