Refactor Product With Children to remove Double Conversion #1745
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.
Summary
$this->getSpecialPrice()
and$this->getTierPrice()
Return a converted price when using multiple currencies, however these prices there converted again a little bit further down the functionExample: Base Currency GBP, Product Price 1200, also shows prices in EUR with a conversion rate of 1.2 (simplified numbers for example)
$this->getSpecialPrice()
will return the Product Final price but converted (1200 * 1.2 = 1440) and then this gets converted again on line 72 (1440 * 1.2 = 1728) giving us an incorrect amount.I have refactored the currency conversion to convert just the final Price and Base Price so that if a special price / Tiered price returns a value then these are converted twice.
Result
prices are only converted when necessary so they are only converted once.