Magento Version : 2.3.0
According to my client requirement, need to remove ".00" decimal places from price range filter on category page layered navigation.
For that please see screenshot :
Please suggest me, how can i achieve it ?
Hello @yagnik_solanki
Please try the below solution:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\Pricing\PriceCurrencyInterface"
type="YourNamespace\YourModule\Model\PriceCurrency" />
</config><?php
namespace YourNamespace\YourModule\Model;
use Magento\Framework\Pricing\PriceCurrencyInterface;
class PriceCurrency extends \Magento\Directory\Model\PriceCurrency implements PriceCurrencyInterface
{
/**
* @inheritdoc
*/
const PRECISION_ZERO = 0;
/**
* {@inheritdoc}
*/
public function format(
$amount,
$includeContainer = true,
$precision = self::PRECISION_ZERO,
$scope = null,
$currency = null
) {
return $this->getCurrency($scope, $currency)
->formatPrecision($amount, $precision, [], $includeContainer);
}
}Source: Magento 2: how to remove decimal values from layered navigation
Hope it helps.
Please try the below solution:
Open the file:
vendor/magento/module-layered-navigation/view/frontend/templates/layer/filter.phtml
At line 23, you'll find:
<?= /* @escapeNotVerified */ $filterItem->getLabel() ?>
Replace it with:
<?php echo str_replace(".00","",$filterItem->getLabel()); ?>
Implement the above steps and you'll get the solution.