I want to display when Add Tier price higher then regular (product)price display as working lower Tier price. If Is possible ? How Can Do it?
-
can u clear your question more– Murtuza ZabuawalaOct 8, 2018 at 6:59
-
Magento2: Tier price lower than regular price working fine but when set Tier price higher than regular price not display product view page working ..– Vishal BaraiyaOct 8, 2018 at 8:03
-
Magento always use lower price to display– Murtuza ZabuawalaOct 8, 2018 at 8:08
-
Thank you for response but is possible to display higher price to display?– Vishal BaraiyaOct 8, 2018 at 8:11
-
yes it is possible– Murtuza ZabuawalaOct 8, 2018 at 8:15
1 Answer
you have to rewrite below class for this
vendor/magento/module-catalog/Model/Product/Type/Price.php
create di.xml
in your module and write below code
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Model\Product\Type\Price" type="[Vendor]\[Module]\Model\Product\Type\Price" />
</config>
and in your [Vendor]\[Module]\Model\Product\Type\Price
Override _applyTierPrice
method change code to below
protected function _applyTierPrice($product, $qty, $finalPrice)
{
if ($qty === null) {
return $finalPrice;
}
$tierPrice = $product->getTierPrice($qty);
if (is_numeric($tierPrice)) {
$finalPrice = $tierPrice; //change this line from orignal code
}
return $finalPrice;
}
-
Thank you for your ans but still not display tier price like see screenshot prntscr.com/l3ikyi Oct 8, 2018 at 10:41
-
-
-