4

I have setup a tier price for my Magento 2 product and I can see the tier price on product details page like below screen shot.

enter image description here

I need to show the same "Buy 3 for $0.00 each and save 100%" in my catalog page also. Is there any way to show like this? Can anyone help me?

  • does catalog page means product list page? – Rita Jose Oct 13 '17 at 7:17
  • @ Rita Jose yes it is – amith lal Oct 13 '17 at 7:32
4

You can add tier prices from admin panel.

Navigate to Admin Panel > Catalog > Product > Add/Edit Product > Advance Pricing (below price input box) > Tier Price > Add

Magento shows tier price in product view page by default. If you want to show tier price in product list page then put below code in your list.phtml file where you want to show tier price.

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>";
    }
}
  • i have alredy added it that's why it showing in product page just check the image the problem is its not showing on catalog page – amith lal Oct 13 '17 at 6:59
  • check my updated answer. – Dinesh Yadav Oct 13 '17 at 8:00
  • @ Dinesh Yadav hey great answer working fine thank you..... – amith lal Oct 13 '17 at 8:36
1
$formattedPrice = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency($price,true,false);

This works better.. The previous if you have prices in the thousands reformatted 7,490.00 to 7.00

0

unfortunally the code does not work for me in list.phml. no products are shown if I put the code to < ? php ... ? > and if I use < ? = ... ? > it gives me a blank page. Can you please specify how to put the code to list.phtml?

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.