getPackageShippingCost returns Packlink API price in service currency without converting to cart currency - #76
Open
matteolavaggi wants to merge 1 commit into
Conversation
Convert API/service prices from the shipping method currency to the cart currency before returning from PackageCostCalculator, and expose all enabled shop currencies in SystemInfoService for multi-currency configuration. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
ShippingCostCurrencyConverterto convert Packlink API/service prices from the shipping method currency to the cart currency using PrestaShopconversion_rate(same logic asTools::convertPriceFull, without requiring front-office context).PackageCostCalculatorto convert costs on every return path before applying shop free-shipping settings.SystemInfoService::getCurrencies()to return all enabled shop currencies viaCurrency::getCurrenciesByIdShop()instead of onlyPS_CURRENCY_DEFAULT.Environment
Steps to reproduce
base_price: 17.96,currency: EUR).Expected
Shipping cost shown and stored in cart currency (NOK), e.g. ~194 NOK for 17.96 EUR (using PS
conversion_rate).Actual (before fix)
EUR amount is passed to PrestaShop unchanged and displayed/stored as NOK, e.g. 23.35 NOK instead of ~252 NOK.
Root cause
PackageCostCalculator::getPackageCost()returnsShippingCostCalculator/ API costs without converting from the shipping method currency to$cart->id_currency.SystemInfoService::getCurrencies()only exposesPS_CURRENCY_DEFAULT, not all shop currencies — related for multi-currency misconfiguration handling.Verification
Manual test:
conversion_ratevs EUR.Test plan
Made with Cursor