5

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?

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

4 Answers 4

9

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>";
    }
}
3
  • 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, 2017 at 6:59
  • check my updated answer. Oct 13, 2017 at 8:00
  • @ Dinesh Yadav hey great answer working fine thank you.....
    – amith lal
    Oct 13, 2017 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?

0

I have the same problem, the function works only on simple products. Would it be possible to make it work in configurables?

I figured out that if you set a tier price higher than the regular price, it will show the regular price anyway. If this is the "normal" functionality, always show the lowest price if it's possible.

But I need to change this functionality, for example set a regular price of $ 10 for a product and $ 15 for a customer group X.

How can I do it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.