2

in magento 1.x for price roud i used extension https://github.com/openstream/Magento5CentRounding Does have somebody any solution for magento 2, or which functions i need rewrite ?

Is https://marketplace.magento.com/pits-module-five-cent-rounding.html a good option?

8
  • Where you want to round the price ? Commented Jan 25, 2017 at 6:01
  • after looking this extension I think you want to round the price on checkout page. Commented Jan 25, 2017 at 6:04
  • @Ramkishan i want to round in catalog, cart, checkout, order, invoice, shipping, emails
    – omelandr
    Commented Jan 25, 2017 at 7:24
  • if you round of price at checkout then round of price will save on db and you will see round price on order,invoice,shipping and emails Commented Jan 25, 2017 at 8:33
  • And for catalog and cart where is mean of round of price ? Commented Jan 25, 2017 at 8:35

2 Answers 2

7

For round the price on checkout page you need to extend

magento2/vendor/magento/module-quote/Model/Quote/Address/Total/Grand.php file.

for rounding grandtotal or base grandtotal in your grand.php (which you have extend) in collect method.

 $total->setGrandTotal(round($totals,0));
 $total->setBaseGrandTotal(round($baseTotals,0));

Using preference you can do this easily. Let me know if you need further assistance. Thank you

2

We looked into this quite a bit. The following options currently exist:

  • comsolit/rappenrunden: This repository is unmaintained and therefore e.g. not PHP 8 compatible. However, it still seems to work.
  • openstream/mage2_rappenrunden: This is a supported fork from comsolit/rappenrunden. It comes with PHP 8 support and some smaller fixes. It seems to work.
  • faonni/module-price: This module actually provides some more price rounding algorithms. Only one of those is the Swiss 5 Rappen rounding. It seems to be maintained and also seems to work.
  • smiso/flexible-price-rounding: This is a fork from faonni/module-price, but honestly, I have no idea which advantage it provides compared to the original module.

All these modules have one flaw, though: If you use qty decimals and e.g. sell a quantity of 1.4 for a product with a unit price of 8.90, they fail. 1.4 * 8.90 makes a row total of 12.46, which would need to be rounded to 12.45. However, all these modules only round the unit price of 8.90, which does not work in this case. We wrote our own module to fix this, but we cannot publish it at the moment. It pretty much overrides \Magento\Tax\Model\Calculation\AbstractAggregateCalculator::calculateWithTaxInPrice and rounds the $rowTotalInclTax in this method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.