Rate code changed to be consistent across multiple rate requests #33
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.
Rate code needs to be consistent accross all rate requests with same request data.
$rate['pk'] can't be used inside shipping method code. Pk (primary key) can change during requests while rates are deleted and requested again. primary key is not a warranted value and depends on rates being available for request across all available methods (more/less methods more/less keys etc)
to illustrate this:
at one reload your rate code can be matrixrate_matrixrate_344
on another reload the same rate can get a different code matrixrate_matrixrate_244
rate deletion is built in to magento totals collection flow, see Magento\Quote\Model\Quote\Address::collectShippingRates() method for details.
This change changes the code do be dependant on rate data instead of random key in database and rate code is unique per requested country + price offered (multiplied by 100)
to illustrate this: