Hi
I need to rounding the cart item totals only both mini cart and one page checkout.
Hello @sainulabidnv
To round the cart item totals in both the mini cart and one-page checkout in Magento 2, please follow the steps below:
$baseTaxDetails = $item->getBaseTaxCalculationDetails(); $taxDetails = $item->getTaxCalculationDetails();and replace the above code block with the following code block:
$baseTaxDetails = $item->getBaseTaxCalculationDetails(); $taxDetails = $item->getTaxCalculationDetails(); // Rounding tax amount $precision = 2; // Change the precision as per your requirement $baseTaxAmount = round($item->getBaseTaxAmount(), $precision); $taxAmount = round($item->getTaxAmount(), $precision); $baseTaxDetails['tax'] = $baseTaxAmount; $taxDetails['tax'] = $taxAmount;4. Save the file and clear the cache.
This will round the tax amount to the specified precision for each item in the cart,
which will be reflected in both the mini cart and one-page checkout.
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9