Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix table rate failing for zip+4 address #17770 #18166

Conversation

magently
Copy link

@magently magently commented Sep 20, 2018

Description

Currently when a customer uses an American ZIP+4 postcode, the table rate shipping method fails to return a quote.

Fixed Issues (if relevant)

  1. Table rate fail when using ZIP+4 shipping address #17770

Manual testing scenarios

  1. Create a Product with weight >= 1.
  2. Enable the Table shipping rate
  3. Import the rate CSV file:
    Country,Region/State,Zip/Postal Code,Weight (and above),Shipping Price
    USA,*,12345,1,2
  4. Create a customer on the frontend with a zip code in the format ZIP+4 (ex: 12345-1234).
  5. Add Product to your cart
  6. Go to checkout

Expected result

  1. The table rate shipping method should ignore the extension and appear with a 2$ shipping fee.

Actual result

  1. The table rate shipping is not present.

The issue is now fixed. If the customer uses a ZIP+4 code (ex: 12345-1234) in case a rate for an exact match (12345-1234) is not found in the table there will be a fallback check for 12345.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Sep 20, 2018

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @magently. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me $VERSION instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@@ -51,7 +52,7 @@ public function prepareSelect(\Magento\Framework\DB\Select $select)
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering why did you remove the line with the star?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at lines 49 and 54 in original code, you will see that there were two identical conditions in this OR statement. So we removed one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@magently yes, I missed that. You are right

* or the part of it prior to the dash in the other case
* @return string
*/
public function getDestPostcodePrefix()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason to make this method public. Do you?

@magently magently force-pushed the fix/extended-zip-code-in-table-rates branch from 381e9de to 6e4a4b2 Compare September 27, 2018 14:30
@magento-engcom-team
Copy link
Contributor

Hi @slavvka, thank you for the review.
ENGCOM-3057 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @magently. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants