Checkout fields priority refactor#21763
Conversation
…causes issues as per #20640 Co-authored-by pierrebuet
Codecov Report
|
claudiulodro
left a comment
There was a problem hiding this comment.
Looks great. Thanks for adding a unit test to prove it works. 👍
|
hi |
|
@masato-igarashi : I confirm, the edit addresses page doesn't sort the fields the way it should. In my original commit, the sorting happens at the source, in the class WC_Countries. The edited commit sorts the fields on the checkout page only. So now the sorting should be done also on the edit pages - or basically each time address fields are requested - too or at the source only once as I suggested. |
|
Cannot do at the source as there are multiple filters in place that can change the fields after the source, we need to accommodate those as well. Working on a fix for the My Account pages. |
All Submissions:
Changes proposed in this Pull Request:
In #20640 it was reported that the trigger to mimic a country select was causing issue, it was then removed which broke the field priority on intial page load. #21733 added back an onselect trigger without knowing it will cause #20640 to happen again.
This PR removes the onselect trigger again and goes with another approach by sorting via PHP, thanks @pierrebuet for the suggestion and idea based on the code you provided. I reworked Pierre's code a bit as it was not working on all the filters you can use to change the checkout fields and also refactored the other uasort methods we have by introducing a new wc_uasort_comparison method which can be reused.
Closes #21642
How to test the changes in this Pull Request:
woocommerce_checkout_fieldsorthe woocommerce_default_address_fieldsor any of the other filters you can use to alter the checkout fields and changes the priority of one of the fields to 1 so it should show right at the top of the checkout page.Other information:
Changelog entry