-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/support postcode restrictions #153
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, mostly to make sure we have considered some things.
includes/class-wc-gateway-amazon-payments-advanced-abstract.php
Outdated
Show resolved
Hide resolved
includes/class-wc-gateway-amazon-payments-advanced-abstract.php
Outdated
Show resolved
Hide resolved
<p> | ||
<?php | ||
esc_html_e( | ||
'Ranges covering thousands or more of postcodes may slow down your site, since Amazon Pay does not support postcode ranges we loop from the minimum until we reach the maximum in order to include them all. Try to use the asterisk (*) wildcard when possible for faster loading times.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test with a large number of postcodes (99k ?) to make sure it works.
If it ends up clogging the payload & making API requests fail, it may be better to try something different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, when using 99k zip codes as range Amazon API fails. Will try to think of an alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's potentially a blocker.
One option would be to notify the user that their settings are "incompatible" with what Amazon supports, and not include those postcodes in the API call - so that it doesn't fail.
But again we would need to know/find what the threshold should be at which we are triggering that scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented an algorithm where ranges are converted to wildcards using the '?' symbol supported by the Amazon API. Let me know your thoughts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good,
Left a comment about the new transient in use.
Also if possible the new stuff could be split into another file, maybe a helper class or somewhere else fitting better. Just to not add to the weight of the file.
Didn't get into how it actually works, the approach looks good, will leave it for QA to figure out where it breaks 🚀
case 'postcode': | ||
$postcode = $location->code; | ||
if ( strstr( $postcode, '...' ) ) { | ||
$pers_ps_array = get_transient( 'woocommerce_amazon_pa_ps_rules_' . self::RANGE_TO_WILDCARDS_ALGO_VERSION . '_' . md5( $postcode ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the called method so heavy that we need a transient?
Usually we want to cache heavy DB queries or calls to remote resources.
Calculations, string operations etc can add up in some cases but here I am not sure a transient will be faster at least on setups without Object caching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea you are right. In most cases, running the method would be less load than querying the DB. I will ask for a extensive QA checks to find out how it works in various cases. Will remove the transient for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👨🎤 🤖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minot comment, not a blocker.
All Submissions:
Changes proposed in this Pull Request:
Closes woo#117 .
How to test the changes in this Pull Request:
Other information:
Changelog entry