0

I want show default tier price in product listing page which we can see on product detail page.

ex. Buy 5 for £47.00 each and save 6%

I can get using of $product->getTierPrice(); in product listing page but it could be better if i can get using tier_prices.phtml via block or any other method.

Please any give any suggestion

  • You need to create he html on listing page by getting information of product. – Dhiren Vasoya Oct 12 at 5:21
  • 1
    i understand but i want use default tier_price.phtml using xml or block – Manish Maheshwari Oct 12 at 5:46
0

Please try with below code in product listing page :

$tier_price = $_product->getTierPrice();

if(count($tier_price) > 0){
foreach($tier_price as $pirces){
    foreach ( array_reverse($pirces) as $key => $value ) {
        if($key == "price"){
            $tierprice = number_format($value, 2, '.', '');
            echo $tierprice;
        }

hope its work for you

  • 1
    i don't want via $_product->getTierPrice() but its working by the way – Manish Maheshwari Oct 12 at 8:45
0

Try below code

if($_product->getTierPrice()){
    $tier_price = $_product->getTierPrice();
    foreach ($tier_price as $key => $value) {
        $qty = (int)$value['price_qty'];
        $price = $value['price'];
        $formattedPrice = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency(number_format($price, 2), true, false);
        $savePercentageFormat = ceil(100 - ( (100 / $_product->getPrice())* $value['price']) ) ."%";

        echo "Buy $qty for ".$formattedPrice." each and save ".$savePercentageFormat;
        echo "<br>";
    }
}
  • how can i achieve using of tier_prices.phtml ? – Manish Maheshwari Oct 14 at 6:26

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.