magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Fewer requests to Shipping Rate module #212

Open andyjv opened 5 years ago

andyjv commented 5 years ago

Description (*)

When entering shipping information at checkout, there are observers on three fields that trigger the script that fetches new shipping rates. Those fields are Zip and Country. When any of those fields are changed a new request for rates is made, and it does not take anything else into account.

As the user enters a postal code, Magento will request rates after about 1 second after the last keypress, regardless of all other facts. If the user is slow, this could result in many requests. There are many reasons why a user would be slow: made a mistake and looking for the mistake; reading the postal code from another source; typing on a phone; any combination of the above.

This multiple request situation could occur of a browsers auto-fill enters in information, and the user goes to change it.

Multiple requests can also occur even if the user is quickly entering information; if just one service provider (UPS or FedEx) is experiencing an issue, it can delay the response.

Most critically, if the request takes longer than one second, depending on user actions, there could be several requests pending at once. Those requests are not required to finish in the order they were made. This can result in invalid shipping rates (or no rates at all).

Expected behavior (*)

Magento should be aware of what information is required before a shipping rate request is made. That information should be validated locally before getting sent to the server for further validation, and only when the information is valid, should a shipping rate be requested. There should only be one active request at a time. If a new request is made, the old one should be cancelled or the new request needs to wait for the original to finish.

Benefits

By improving the way Magento requests shipping rates, there are several benefits to both merchants and shoppers:

Additional information

magento-engcom-team commented 5 years ago

Hi @andyjv. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop). For more details, please, review the Magento Contributor Assistant documentation.

@andyjv do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

magento-engcom-team commented 5 years ago

Hi @engcom-backlog-pb. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 5 years ago

@engcom-backlog-pb Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-95792, MAGETWO-95793 were created

webkul-ratnesh commented 5 years ago

I think only following the flow to restrict one ajax request at a time, will solve this issue. Because as per the concern regarding mobile data usage, the request and response will have total overhead of 700 bytes to 1 Kilo bytes, and that is not a matter of concern. Regarding the concern of validation at browser end, The shipping method estimation is based on the information only:

  1. State
  2. Postal code
  3. Country

The scope of all three field's value is very vast and validations are already made on it.