I can set Normal price along with Special price while put custom function in core file
vendor/magento/module-weee/Block/Item/Price/Renderer.php
public function getUnitItemPriceExclTax()
{
$priceExclTax = $this->getItem()->getProduct()->getPrice();
return $priceExclTax;
}
And calling this function into core file,
vendor/magento/module-weee/view/frontend/templates/checkout/cart/item/price/sidebar.phtml
So getting both price correctly, but i want to override that
vendor/magento/module-weee/Block/Item/Price/Renderer.php
block on my custom module.
I have created di.xml with below code :
<preference for="Magento\Weee\Block\Item\Price\Renderer" type="<namespace\<module_name>\Block\Item\Price\Renderer"/>
And just put that getUnitItemPriceExclTax()
function in that block.
Best Answer
You dont need to override Renderer.php file in core and you should never do in core. You can just changes in sidebar.phtml file and set your changes.
You can get price from below method:
After getting above changes you can do it below code in your template file:
I have done changes in Magento Version 2.1.1.