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

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

2 Answers 2

1

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>";
    }
}
1
  • how can i achieve using of tier_prices.phtml ? Oct 14, 2019 at 6:26
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
  • 1
    i don't want via $_product->getTierPrice() but its working by the way Oct 12, 2019 at 8:45

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.