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

Address form can't unset a State when editing #1162

Closed
ghost opened this issue Dec 3, 2019 · 1 comment
Closed

Address form can't unset a State when editing #1162

ghost opened this issue Dec 3, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 3, 2019

Description

I've tested this with your sample templates to make sure it wasn't something I'd done.

If you have an address with a state, say US and Florida, then if you come to edit the record and change country to somewhere that doesn't require a state, say UK, then when you save the record still shows Florida as the selected state.

The only way it works is to put a non null string in the 'stateName' field, which isn't ideal.

Not sure when the state fields switched to using stateValue instead of the separate stateId and stateName, but I find it messier this way.

Bug seems to stem from the if statement on line 476 of models/Address.php as an empty string or '0' evaluate to False and therefore the stateId and and stateName don't get changed.

Steps to reproduce

  1. Create a new US address and select a State.
  2. Save
  3. Edit the address, set Country to one without state, e.g France.
  4. Save.
  5. The address still has the previously selected State

Additional info

  • Craft version: 3.3.16.3
  • PHP version: 7.3.11
  • Database driver & version: MySQL 5.7.27
  • Plugins & versions: Craft Commerce 2.2.8
@lukeholder
Copy link
Member

Fixed as above.

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