Feature rounding options configurable from admin. Related #677, #1424 #1983
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because RoundingHelper.RoundPrice handles all rounding, I would like to suggest adding the ability to configure some basic settings for how the rounding is handled.
The first option (RoundingPrecision) allows users to pass in the number of decimal places they would like to round to. Default would be 2. Right now there is no validation if a user enters a negative number. I could add it if suggested.
The second option (UseRoundingPrecisionForPriceDisplay) is would mostly be used by b2b implimentations where a buyer might want to see the entire price. In this case the same number of digits used for rounding would also be shown for the price on a product. It is disabled by default to use the standard 2 places.
The third option (RoundAwayFromZero ) just allows the admin to use this as a rounding options. While there has not been a lot of demand for this, it has come up.
Lastly, I am passing the Catalog Settings into the helper method so that the helper method does not have to resolve the settings. In most cases the settings were already loaded in the class where the helper method is being used.
By allowing these features out of the box, it would make it easy for plugin developers to handle these cases without modifying core code or over-riding many services, especially since all of this logic passes through the single line of code in the RoundingHelper.