Skip to content

Conversation

@speedupmate
Copy link

@speedupmate speedupmate commented Sep 3, 2017

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:

  • rate code for Finland with price 19.00 will become matrixrate_matrixrate_FI1900
  • rate code for USA with price 19.00 will become matrixrate_matrixrate_US1900

…request data

Rate code needs to be consistent accross all request to rates with same request data. 

Depending on $rate['pk']  can't be used cause pk (primary key) can change during requests while rates are deleted and requested again as primary key is not a warranted value and depends on rates being available for request across all available methods 

rate deletion is built in to magento totals collection flow, see  Magento\Quote\Model\Quote\Address::collectShippingRates() method for details.
@speedupmate speedupmate changed the title Rate code changed to be consistent across multipel request with same … Rate code changed to be consistent across multiple rate requests Sep 3, 2017
@wsagen
Copy link
Contributor

wsagen commented Sep 5, 2017

Hi Anton,

The "pk" value is the unique identifier for a rate (i.e. the table row) and will only change for that particular rate when a new CSV file is uploaded.
If you are not seeing the same rates returned during checkout flow, then there must be a difference in the request to Matrixrates meaning different rates are being returned.

If you enable logging you can view the rate requests and rows retrieved.

It's likely one of the outstanding issues with Magento 2 is the issue here, where the full address is not sent to carriers during the shipping method step, and is used during the payment and review step. So for example, if your CSV file includes region or postcode filtering, then there may be a difference in the actual rate returned.

We can't accept this change as it would break the uniqueness constraint on the shipping method code for many of our customer's CSV files. It's extremely common that customers would have identical rates for the same country, across many rows in a CSV file and this change would mean all of those rates had the exact same method code and were no longer unique.

@wsagen wsagen closed this Sep 5, 2017
@speedupmate speedupmate deleted the develop branch September 6, 2017 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants