craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
225 stars 170 forks source link

getAllEnabledStatesAsListGroupedByCountryId returns states in random order #1512

Closed brianjhanson closed 4 years ago

brianjhanson commented 4 years ago

Description I'm not sure if this is really a bug, but the getAllEnabledStatesAsListGroupedByCountryId seems to return states in a random order on every refresh.

To Reproduce Output `{% dd craft.commerce.states.getAllEnabledStatesAsListGroupedByCountryId %} and refresh. On each refresh the order seems to change.

Video of the output

Expected behavior I expected them to be ordered alphabetically.

Additional info

Asset Rev 6.0.2
Cookies 1.1.12
Craft Commerce 3.1.3
Feed Me 4.2.2
Freeform 3.6.7
Gift Voucher 2.3.0
Klaviyo Connect 3.1.3.2
one-campaign-monitor dev-feature/craft-3
One Imgix dev-craft-3
PayPal Checkout for Craft Commerce 1.1.0
PayPal for Craft Commerce 2.1.0.1
Rackspace Cloud Files dev-feature/parse-env-vars
Redactor 2.6.1
SEOmatic 3.3.2
ShipStation Connect 1.3.2
Stripe for Craft Commerce 2.3.0
lukeholder commented 4 years ago

Thanks for reporting that! I’ve just fixed it for the next release.

You can work around the bug without waiting for the release by just sorting one country in the country list manually within the CP, and same for each group of states inside each country.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "dev-develop#fb4cba2f85a36d4a25c3fdd760256d66d8f4bb0a as 3.1.8",
  "...": "..."
}

Then run composer update.

Thanks.

brianjhanson commented 4 years ago

Thanks @lukeholder!