11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/services/spree/seeds/states.rb', line 11
def call
Spree::Country.where(states_required: true).each do |country|
carmen_country = Carmen::Country.named(country.name)
next unless carmen_country
carmen_country.subregions.each do |subregion|
if carmen_country.alpha_2_code == 'US'
next if EXCLUDED_US_STATES.include?(subregion.code)
state_level(country, subregion)
elsif carmen_country.alpha_2_code == 'CA' || carmen_country.alpha_2_code == 'MX'
state_level(country, subregion)
elsif carmen_country.alpha_2_code == 'CN'
next if EXCLUDED_CN_STATES.include?(subregion.code)
state_level(country, subregion)
elsif subregion.subregions?
province_level(country, subregion)
else
state_level(country, subregion)
end
end
end
end
|