Sha256: f2c71fcb02ec795acf9f3b85ab0b3a48b383ae695c3360a11561244c809a6db9

Contents?: true

Size: 958 Bytes

Versions: 21

Compression:

Stored size: 958 Bytes

Contents

require 'carmen'

EXCLUDED_COUNTRIES = ['AQ', 'AX', 'GS', 'UM', 'HM', 'IO', 'EH', 'BV', 'TF'].freeze

Carmen::Country.all.each do |country|
  # Skip the creation of some territories, uninhabited islands and the Antarctic.
  next if EXCLUDED_COUNTRIES.include?(country.alpha_2_code)

  Spree::Country.where(
    name: country.name,
    iso3: country.alpha_3_code,
    iso: country.alpha_2_code,
    iso_name: country.name.upcase,
    numcode: country.numeric_code
  ).first_or_create
end

Spree::Config[:default_country_id] = Spree::Country.find_by(iso: 'US').id

# Find countries that do not use postal codes (by iso) and set 'zipcode_required' to false for them.
Spree::Country.where(iso: Spree::Address::NO_ZIPCODE_ISO_CODES).update_all(zipcode_required: false)

# Find all countries that require a state (province) at checkout and set 'states_required' to true.
Spree::Country.where(iso: Spree::Address::STATES_REQUIRED).update_all(states_required: true)

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
spree_core-4.2.7 db/default/spree/countries.rb
spree_core-4.3.3 db/default/spree/countries.rb
spree_core-4.2.6 db/default/spree/countries.rb
spree_core-4.3.2 db/default/spree/countries.rb
spree_core-4.3.1 db/default/spree/countries.rb
spree_core-4.3.0 db/default/spree/countries.rb
spree_core-4.3.0.rc3 db/default/spree/countries.rb
spree_core-4.3.0.rc2 db/default/spree/countries.rb
spree_core-4.3.0.rc1 db/default/spree/countries.rb
spree_core-4.2.5 db/default/spree/countries.rb
spree_core-4.2.4 db/default/spree/countries.rb
spree_core-4.2.3.1 db/default/spree/countries.rb
spree_core-4.2.3 db/default/spree/countries.rb
spree_core-4.2.2 db/default/spree/countries.rb
spree_core-4.2.1 db/default/spree/countries.rb
spree_core-4.2.0 db/default/spree/countries.rb
spree_core-4.2.0.rc5 db/default/spree/countries.rb
spree_core-4.2.0.rc4 db/default/spree/countries.rb
spree_core-4.2.0.rc3 db/default/spree/countries.rb
spree_core-4.2.0.rc2 db/default/spree/countries.rb