-
Notifications
You must be signed in to change notification settings - Fork 207
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
feat: For Shipping Zones Zip Regex - Correctly handle UK postcodes redacted by Apple Pay #3592
Conversation
includes/payment-methods/class-wc-stripe-express-checkout-helper.php
Outdated
Show resolved
Hide resolved
includes/payment-methods/class-wc-stripe-express-checkout-helper.php
Outdated
Show resolved
Hide resolved
includes/payment-methods/class-wc-stripe-express-checkout-helper.php
Outdated
Show resolved
Hide resolved
includes/payment-methods/class-wc-stripe-express-checkout-helper.php
Outdated
Show resolved
Hide resolved
Hey @majikandy ! Thank you for your contribution! I took the liberty of fixing and updating your PR with the suggestions and linting issues. I also added the changelog and readme entries. As well as specific unit tests. Since we tested and approved it, I decided to merge it already 👍 |
@wjrosa Amazing, thank you. I was already using my fork effectively on my own shop so I'm really happy you (all) picked this up and got it in properly. I would have got round to it but have been taking a break from the computer for a couple of weeks. Hope you liked the change. |
Thank you for your hard work. And have fun on your break! |
Improved upon idea in #2646 So that user does not need to add special syntax into shipping zones regex
Fixes #2645
Changes proposed in this Pull Request:
UK Postcodes consist of an outcode 2,3 or 4 characters long, then an optional space, and then 3 more characters.
Apple Pay intelligently truncates the UK postcode removing the outcode. Futhermore It keeps the optional space at the end of it's redacted string if it was there in the original.
With this behaviour known, we need to code it more intelligently when padding with stars than just assuming a UK postcode is 7 characters long.
This PR implements that behaviour.
This also enabled full support for the Regex within Shipping Zones so that Regex like
N1 *
(N1 space star) correctly match postcodes like N12AA and N1 2AA to mean all N1 postcodes and correctly avoids accidental matches of N10, N11, N12 postcodes etcThis enabled proper bevaviour of shipping zones such that a user can ship to N1 for one price and N19 for another. The main scenario of this is an artistan seller/maker who will drive or walk to N1 to hand deliver, but won't to N19 without a fee (or even not at all)
Questions for the PR author:
If Apple changed the way it redacts the postcodes
if the truncated postcode excluding space is more than 5 characters, it just returns it as is as it is highly likely it is has not been truncated. This is because it would be a bad implementation by a third party to truncate a postcode to 5 chars for privacy reasons, when many true valid postcodes are 5 characters long.
Also the only impact of the postcode not validating is that shipping zones come up wrong due to non matches of the truncated/altered postcode. Therefore the behaviour cannot be made any worse than now.
Testing instructions
Admin: Enable Apple pay via Stripe on the Basket
Admin: Setup shipping zones with a regex like 'N1 *' for free and 'N10 * for a fee.
Customer: Setup addresses in your real apple pay on your device eg N1 4AB, N10 5BC, N11AA, N191AA (you can set any addresses as you don't need to complete purchases or validate addresses)
Customer: Add items to the basket
Customer: for each of the addresses in apple pay
Unit tests not added as this piece of code yet as it didn't have any before - however can easily add some if this change is likely to progress into the codebase
changelog.txt
andreadme.txt
(or does not apply)Post merge