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

Change state_required detections #3807

Conversation

DanielePalombo
Copy link
Contributor

@DanielePalombo DanielePalombo commented Oct 23, 2020

Carmen::Country#subregions? returns true even if the subregions aren't states.
With this commit state_required variable will set true only when there is at least one nested state.

To update existing countries you can execute the following command on the console.

require 'carmen'

carmen_countries = Carmen::Country.all

Spree::Country.all.each do |country|
  next if carmen_countries.detect { |c| c.name == country.name }.subregions.any? { |c| c.subregions.detect { |r| r.type == 'state' } }
  
  country.update(states_required: false)
end

Ref #3803

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

`Carmen::Country#subregions?` returns true even if the subregions aren't
states.
With this commit state_required variable will set true only when there
is at least one nested state.
@DanielePalombo DanielePalombo marked this pull request as ready for review October 23, 2020 13:06
@kennyadsl
Copy link
Member

I'm not sure to get this. How having states as subregions and subregion being required are connected. For example, in Italy we have provinces, which are not states and they are required in the address.

@DanielePalombo DanielePalombo marked this pull request as draft October 26, 2020 09:08
@waiting-for-dev
Copy link
Contributor

Closing in favor of #3842 to properly define all the logic involved here.

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

Successfully merging this pull request may close these issues.

3 participants