Skip to content

Commit

Permalink
Merge pull request #567 from ajkamel/ak-updates-country-to-iso
Browse files Browse the repository at this point in the history
adds country lookup by ISO
  • Loading branch information
cbrunsdon committed Dec 8, 2015
2 parents 61535f9 + b08f40e commit 996aa40
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/db/default/spree/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Spree::Country.create!(countries)
end

Spree::Config[:default_country_id] = Spree::Country.find_by(name: "United States").id
Spree::Config[:default_country_id] ||= Spree::Country.find_by(iso: "US").id
16 changes: 5 additions & 11 deletions core/db/default/spree/zones.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
eu_vat = Spree::Zone.find_or_create_by!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.")
north_america = Spree::Zone.find_or_create_by!(name: "North America", description: "USA + Canada")

["Poland", "Finland", "Portugal", "Romania", "Germany", "France",
"Slovakia", "Hungary", "Slovenia", "Ireland", "Austria", "Spain",
"Italy", "Belgium", "Sweden", "Latvia", "Bulgaria", "United Kingdom",
"Lithuania", "Cyprus", "Luxembourg", "Malta", "Denmark", "Netherlands",
"Estonia", "Croatia", "Czech Republic", "Greece"].
each do |name|
eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(name: name))
%w(PL FI PT RO DE FR SK HU SI IE AT ES IT BE SE LV BG GB LT CY LU MT DK NL EE).
each do |symbol|
eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(iso: symbol))
end

["United States", "Canada"].each do |name|
north_america.zone_members.create!(zoneable: Spree::Country.find_by!(name: name))
%w(US CA).each do |symbol|
north_america.zone_members.create!(zoneable: Spree::Country.find_by!(iso: symbol))
end


2 changes: 1 addition & 1 deletion sample/db/samples/addresses.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
united_states = Spree::Country.find_by_name!("United States")
united_states = Spree::Country.find_by_iso!("US")
new_york = Spree::State.find_by_name!("New York")

# Billing address
Expand Down

0 comments on commit 996aa40

Please sign in to comment.