This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Fix state validation to compare state codes, and only validate if a country is given #5132
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rubikuserbot
requested review from
a team and
senadir
and removed request for
a team
November 12, 2021 11:36
Size Change: +10 B (0%) Total Size: 1.11 MB
ℹ️ View Unchanged
|
Pause on this. Might be some confusion between names and codes: #5131 (comment) |
mikejolley
added
the
status: blocker
Used on issues or pulls that block work from being released.
label
Nov 15, 2021
Pushed some changes to correcrly match against the state code rather than the value. Should be ok now. |
mikejolley
changed the title
Only get valid states from wc if there is a country
Fix state validation to compare state codes, and only validate if a country is given
Nov 15, 2021
nielslange
added
type: bug
The issue/PR concerns a confirmed bug.
skip-changelog
PRs that you don't want to appear in the changelog.
labels
Nov 16, 2021
senadir
approved these changes
Nov 16, 2021
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.
Code changes look wonderful and this is testing as expected!
github-actions
bot
added
status: ready to merge
and removed
status: needs review
labels
Nov 16, 2021
nielslange
pushed a commit
that referenced
this pull request
Nov 17, 2021
…ountry is given (#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys
nielslange
added a commit
that referenced
this pull request
Nov 17, 2021
* Empty commit for release pull request * Fix state validation to compare state codes, and only validate if a country is given (#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys * Fix 'Country is required' error on the Cart block when updating shipping address (#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir <[email protected]> * Make order note block removable (#5139) * unforce order note * show block in inserter * Mini Cart block fatal error caused by append_script_and_deps_src (#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping * Replace do_action_deprecated with the WC equivalent (#5151) * Remove feature gate condition for Legacy Template block (#5158) * Update readme.txt * Update testing instructions * Bumping version strings to new version. Co-authored-by: github-actions <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Niels Lange <[email protected]>
nielslange
added a commit
that referenced
this pull request
Nov 17, 2021
* Empty commit for release pull request * Update readme.txt with release changelog * Add testing instructions for 6.3.0 release * Update testing instructions as MD tables didn't work * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update docs/testing/releases/630.md Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update readme.txt * Update release zip in testing note * Update testing instructions * Remove feature gate condition for Legacy Template block (#5158) * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt * Update testing instructions * Update testing instructions * Update release zip in testing note * Update testing instructions for SE templates * Update testing instructions for SE templates II * Update testing instructions * Bumping version strings to new version. * Release: 6.3.1 (#5169) * Empty commit for release pull request * Fix state validation to compare state codes, and only validate if a country is given (#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys * Fix 'Country is required' error on the Cart block when updating shipping address (#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir <[email protected]> * Make order note block removable (#5139) * unforce order note * show block in inserter * Mini Cart block fatal error caused by append_script_and_deps_src (#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping * Replace do_action_deprecated with the WC equivalent (#5151) * Remove feature gate condition for Legacy Template block (#5158) * Update readme.txt * Update testing instructions * Bumping version strings to new version. Co-authored-by: github-actions <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Michael P. Pfeiffer <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]>
nielslange
added a commit
that referenced
this pull request
Nov 18, 2021
* Empty commit for release pull request * Update readme.txt with release changelog * Add testing instructions for 6.3.0 release * Update testing instructions as MD tables didn't work * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update docs/testing/releases/630.md Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update readme.txt * Update release zip in testing note * Update testing instructions * Remove feature gate condition for Legacy Template block (#5158) * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt * Update testing instructions * Update testing instructions * Update release zip in testing note * Update testing instructions for SE templates * Update testing instructions for SE templates II * Update testing instructions * Bumping version strings to new version. * Empty commit for release pull request * Fix state validation to compare state codes, and only validate if a country is given (#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys * Fix 'Country is required' error on the Cart block when updating shipping address (#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir <[email protected]> * Make order note block removable (#5139) * unforce order note * show block in inserter * Mini Cart block fatal error caused by append_script_and_deps_src (#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping * Replace do_action_deprecated with the WC equivalent (#5151) * Remove feature gate condition for Legacy Template block (#5158) * Update readme.txt * Update testing instructions * Bumping version strings to new version. * Empty commit for release pull request * Update readme.txt * Add testing instructions * Add testing notes to README.md * Hide WooCommmerce block templates from Edit Post template dropdown (#5167) * Hide WooCommmerce block templates from Edit Post template dropdown * Add empty post_types value to template and update comments. * Legacy Template Block: Remove the deletion lock (#5166) Previously, our legacy template block was locked to prevent the users from removing it. The block could however be removed by erasing the parent, so this change allows the user to directly remove the block itself. Also: Closes #5163 Closes #5109 * Update release zip * Update release zip * Update testing instructions * Bumping version strings to new version. Co-authored-by: github-actions <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Michael P. Pfeiffer <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]> Co-authored-by: Lucio Giannotta <[email protected]>
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 14, 2021
…ountry is given (woocommerce#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 14, 2021
* Empty commit for release pull request * Update readme.txt with release changelog * Add testing instructions for 6.3.0 release * Update testing instructions as MD tables didn't work * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update docs/testing/releases/630.md Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update readme.txt * Update release zip in testing note * Update testing instructions * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt * Update testing instructions * Update testing instructions * Update release zip in testing note * Update testing instructions for SE templates * Update testing instructions for SE templates II * Update testing instructions * Bumping version strings to new version. * Release: 6.3.1 (woocommerce#5169) * Empty commit for release pull request * Fix state validation to compare state codes, and only validate if a country is given (woocommerce#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys * Fix 'Country is required' error on the Cart block when updating shipping address (woocommerce#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir <[email protected]> * Make order note block removable (woocommerce#5139) * unforce order note * show block in inserter * Mini Cart block fatal error caused by append_script_and_deps_src (woocommerce#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping * Replace do_action_deprecated with the WC equivalent (woocommerce#5151) * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update readme.txt * Update testing instructions * Bumping version strings to new version. Co-authored-by: github-actions <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Michael P. Pfeiffer <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]>
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 14, 2021
* Empty commit for release pull request * Update readme.txt with release changelog * Add testing instructions for 6.3.0 release * Update testing instructions as MD tables didn't work * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update docs/testing/releases/630.md Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update readme.txt * Update release zip in testing note * Update testing instructions * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt * Update testing instructions * Update testing instructions * Update release zip in testing note * Update testing instructions for SE templates * Update testing instructions for SE templates II * Update testing instructions * Bumping version strings to new version. * Empty commit for release pull request * Fix state validation to compare state codes, and only validate if a country is given (woocommerce#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys * Fix 'Country is required' error on the Cart block when updating shipping address (woocommerce#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir <[email protected]> * Make order note block removable (woocommerce#5139) * unforce order note * show block in inserter * Mini Cart block fatal error caused by append_script_and_deps_src (woocommerce#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping * Replace do_action_deprecated with the WC equivalent (woocommerce#5151) * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update readme.txt * Update testing instructions * Bumping version strings to new version. * Empty commit for release pull request * Update readme.txt * Add testing instructions * Add testing notes to README.md * Hide WooCommmerce block templates from Edit Post template dropdown (woocommerce#5167) * Hide WooCommmerce block templates from Edit Post template dropdown * Add empty post_types value to template and update comments. * Legacy Template Block: Remove the deletion lock (woocommerce#5166) Previously, our legacy template block was locked to prevent the users from removing it. The block could however be removed by erasing the parent, so this change allows the user to directly remove the block itself. Also: Closes woocommerce#5163 Closes woocommerce#5109 * Update release zip * Update release zip * Update testing instructions * Bumping version strings to new version. Co-authored-by: github-actions <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Michael P. Pfeiffer <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]> Co-authored-by: Lucio Giannotta <[email protected]>
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 16, 2021
…ountry is given (woocommerce#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 16, 2021
* Empty commit for release pull request * Update readme.txt with release changelog * Add testing instructions for 6.3.0 release * Update testing instructions as MD tables didn't work * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update docs/testing/releases/630.md Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update readme.txt * Update release zip in testing note * Update testing instructions * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt * Update testing instructions * Update testing instructions * Update release zip in testing note * Update testing instructions for SE templates * Update testing instructions for SE templates II * Update testing instructions * Bumping version strings to new version. * Release: 6.3.1 (woocommerce#5169) * Empty commit for release pull request * Fix state validation to compare state codes, and only validate if a country is given (woocommerce#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys * Fix 'Country is required' error on the Cart block when updating shipping address (woocommerce#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir <[email protected]> * Make order note block removable (woocommerce#5139) * unforce order note * show block in inserter * Mini Cart block fatal error caused by append_script_and_deps_src (woocommerce#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping * Replace do_action_deprecated with the WC equivalent (woocommerce#5151) * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update readme.txt * Update testing instructions * Bumping version strings to new version. Co-authored-by: github-actions <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Michael P. Pfeiffer <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]>
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 16, 2021
* Empty commit for release pull request * Update readme.txt with release changelog * Add testing instructions for 6.3.0 release * Update testing instructions as MD tables didn't work * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update docs/testing/releases/630.md Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update readme.txt * Update release zip in testing note * Update testing instructions * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update testing instructions * Update testing instructions * Update testing instructions * Update readme.txt * Update testing instructions * Update testing instructions * Update release zip in testing note * Update testing instructions for SE templates * Update testing instructions for SE templates II * Update testing instructions * Bumping version strings to new version. * Empty commit for release pull request * Fix state validation to compare state codes, and only validate if a country is given (woocommerce#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys * Fix 'Country is required' error on the Cart block when updating shipping address (woocommerce#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir <[email protected]> * Make order note block removable (woocommerce#5139) * unforce order note * show block in inserter * Mini Cart block fatal error caused by append_script_and_deps_src (woocommerce#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping * Replace do_action_deprecated with the WC equivalent (woocommerce#5151) * Remove feature gate condition for Legacy Template block (woocommerce#5158) * Update readme.txt * Update testing instructions * Bumping version strings to new version. * Empty commit for release pull request * Update readme.txt * Add testing instructions * Add testing notes to README.md * Hide WooCommmerce block templates from Edit Post template dropdown (woocommerce#5167) * Hide WooCommmerce block templates from Edit Post template dropdown * Add empty post_types value to template and update comments. * Legacy Template Block: Remove the deletion lock (woocommerce#5166) Previously, our legacy template block was locked to prevent the users from removing it. The block could however be removed by erasing the parent, so this change allows the user to directly remove the block itself. Also: Closes woocommerce#5163 Closes woocommerce#5109 * Update release zip * Update release zip * Update testing instructions * Bumping version strings to new version. Co-authored-by: github-actions <[email protected]> Co-authored-by: Niels Lange <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Michael P. Pfeiffer <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Nadir Seghir <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]> Co-authored-by: Lucio Giannotta <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
skip-changelog
PRs that you don't want to appear in the changelog.
status: blocker
Used on issues or pulls that block work from being released.
type: bug
The issue/PR concerns a confirmed bug.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reported in #5131, and introduced in #4844:
wc()->countries->get_states()
returns the states of all countries keyed by country code.This avoids the issue by checking if there is a country before getting an array of states, and then doing the validation based on state code.
Closes #5131
Testing
#5131 has testing steps but these only apply due to a separate bug where billing data is not populated (due to hydration). I tested this only by logging data in the route to ensure correct states were populated.
The validation changes can also be tested by making requests to the API to verify validation is working. First disable nonce checks with:
Then add something to cart in your rest api client, e.g. POST to
https://store.local/wp-json/wc/store/cart/add-item
with:Then POST to checkout
https://store.local/wp-json/wc/store/checkout
:Try changing the state and ensure the response shows the parameter error.
Changelog