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

States (regions) become unsorted by frontend JS #2351

Open
leewillis77 opened this issue Nov 6, 2017 · 0 comments
Open

States (regions) become unsorted by frontend JS #2351

leewillis77 opened this issue Nov 6, 2017 · 0 comments

Comments

@leewillis77
Copy link
Contributor

In a standard installation, the states (regions) of countries are created in such a way that they are alphabetically ordered with incrementing IDs. However, if you were to modify the names of regions, or add new regions but do not add them in alphabetical order then they will be displayed incorrectly on the frontend.

The easiest way to reproduce is to add some additional regions to wp_wpsc_region_tax table in non-alphabetical sequence.

In my example, I added some regions to the United Kingdom:

| 65 |        223 | North west                | NW   |   0 |
| 66 |        223 | East                      | E    |   0 |
| 67 |        223 | West                      | W    |   0 |
| 68 |        223 | South                     | S    |   0 |
| 69 |        223 | North East                | NE   |   0 |

As you can see, these were not added in alphabetical order.

If you visit the checkout process, with the United Kingdom as your country, but with Javascript disabled then the region list shows correctly.

screenshot 2017-11-06 09 40 55

However, if you visit checkout with Javascript enabled, then the Javascript that rebuilds the region list according to the selected country outputs the regions in ID order:

screenshot 2017-11-06 09 43 42

The relevant code appears to be wpsc_update_regions_list_to_match_country() in wp-e-commerce.js

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

No branches or pull requests

1 participant