Question

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?

Was it helpful?

Solution

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

OTHER TIPS

$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

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?

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top