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>";
    }
}
?>

1 Answer 1

1
<?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']; 
        $price = $value['price'];
        $savePercentage = round(100 - ( (100 / $_product->getPrice())* $price) ) ."%";
        $regular_price_of_custom_tot = $regular_price_of_custom - (($regular_price_of_custom * $savePercentage) / 100);
        $formattedTierPrice = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency(number_format($regular_price_of_custom_tot, 2), true, false);

        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>";

    }
}

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.