Sha256: a98566c669ff5a2c2282b6b49a8ec9d6fc5a2c75869530115286be81482e37d5
Contents?: true
Size: 1.8 KB
Versions: 65
Compression:
Stored size: 1.8 KB
Contents
begin north_america = Spree::Zone.find_by_name!("North America") rescue ActiveRecord::RecordNotFound puts "Couldn't find 'North America' zone. Did you run `rake db:seed` first?" puts "That task will set up the countries, states and zones required for Spree." exit end europe_vat = Spree::Zone.find_by_name!("EU_VAT") shipping_category = Spree::ShippingCategory.find_or_create_by!(name: 'Default') Spree::ShippingMethod.create!([ { :name => "UPS Ground (USD)", :zones => [north_america], :calculator => Spree::Calculator::Shipping::FlatRate.create!, :shipping_categories => [shipping_category] }, { :name => "UPS Two Day (USD)", :zones => [north_america], :calculator => Spree::Calculator::Shipping::FlatRate.create!, :shipping_categories => [shipping_category] }, { :name => "UPS One Day (USD)", :zones => [north_america], :calculator => Spree::Calculator::Shipping::FlatRate.create!, :shipping_categories => [shipping_category] }, { :name => "UPS Ground (EU)", :zones => [europe_vat], :calculator => Spree::Calculator::Shipping::FlatRate.create!, :shipping_categories => [shipping_category] }, { :name => "UPS Ground (EUR)", :zones => [europe_vat], :calculator => Spree::Calculator::Shipping::FlatRate.create!, :shipping_categories => [shipping_category] } ]) { "UPS Ground (USD)" => [5, "USD"], "UPS Ground (EU)" => [5, "USD"], "UPS One Day (USD)" => [15, "USD"], "UPS Two Day (USD)" => [10, "USD"], "UPS Ground (EUR)" => [8, "EUR"] }.each do |shipping_method_name, (price, currency)| shipping_method = Spree::ShippingMethod.find_by_name!(shipping_method_name) shipping_method.calculator.preferences = { amount: price, currency: currency } shipping_method.calculator.save! shipping_method.save! end
Version data entries
65 entries across 65 versions & 3 rubygems