Basically, You need to override dependency file of priceCurrency interface by below way to change precision of price.
You can set precision of price using below way,
Just need to create a simple module for it,
Create Rbj/PriceCurrency module under the app/code folder Magento.
Create registration.php file,
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Rbj_PriceCurrency',
__DIR__
);
create etc folder,
app/code/Rbj/PriceCurrency/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Rbj_PriceCurrency" setup_version="1.0.0">
<sequence>
<module name="Magento_Backend"/>
<module name="Magento_Directory"/>
</sequence>
</module>
</config>
app/code/Rbj/PriceCurrency/etc/di.xml
<?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\Directory\Model\Currency" type="Rbj\PriceCurrency\Model\Directory\Currency" />
</config>
app/code/Rbj/PriceCurrency/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\Locale\Format">
<plugin name="format-price" type="Rbj\PriceCurrency\Plugin\FormatPrice" sortOrder="10" />
</type>
</config>
Create model file which we have decalred in di.xml file,
app/code/Rbj/PriceCurrency/Model/Directory/Currency.php
<?php
namespace Rbj\PriceCurrency\Model\Directory;
class Currency extends \Magento\Directory\Model\Currency
{
/*
* You can set precision from here in $options array
*/
public function formatTxt($price, $options = [])
{
if (!is_numeric($price)) {
$price = $this->_localeFormat->getNumber($price);
}
$price = sprintf("%F", $price);
$options['precision'] = 0;
return $this->_localeCurrency->getCurrency($this->getCode())->toCurrency($price, $options);
}
}
Create app/code/Rbj/PriceCurrency/Plugin/FormatPrice.php
<?php
namespace Rbj\PriceCurrency\Plugin;
class FormatPrice
{
/*
* Returns an array with price formatting info
*
* \Magento\Framework\Locale\Format $subject
*/
public function aroundGetPriceFormat(\Magento\Framework\Locale\Format $subject, callable $proceed, $localeCode = null, $currencyCode = null)
{
$returnValue = $proceed($localeCode, $currencyCode);
$returnValue['requiredPrecision'] = 0;
return $returnValue;
}
}
Run php bin/magento setup:upgrade
command.