Sunday, 9 September 2018

Magento 2 : [SOLUTION] Tier price saving percentage wrong when Tax/Vat is included in price

Solution:

Magento2 ver. 2.1.5, 2.1.7 

Going to 'vendor/magento/module-catalog/Pricing/Price/TierPrice.php

Line No 209

public function getSavePercent(AmountInterface $amount)
    {
       return ceil(
            100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue())
                * $amount->getBaseAmount())
        );        
       

    }


Replace to :

public function getSavePercent(AmountInterface $amount)
    {
        /*return ceil(
            100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue())
                * $amount->getBaseAmount())
        );*/
        
        $productPriceAmount = $this->priceInfo->getPrice(
            FinalPrice::PRICE_CODE
        )->getAmount();

        return round(
            100 - ((100 / $productPriceAmount->getValue()) * $amount->getValue())
        );

    }


No comments:

Post a Comment