diff --git a/app/models/spree/distributor.rb b/app/models/spree/distributor.rb index ae309b250b..7db9684a58 100644 --- a/app/models/spree/distributor.rb +++ b/app/models/spree/distributor.rb @@ -3,7 +3,14 @@ module Spree set_table_name 'distributors' has_many :orders belongs_to :country + belongs_to :state - validates :name, :pickup_address, :country_id, :city, :post_code, :presence => true + validates :name, :pickup_address, :country_id, :state_id, :city, :post_code, :presence => true + + after_initialize :initialize_country + + def initialize_country + # self.country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) + end end end diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb index 95f41c8234..4a38447903 100644 --- a/app/models/spree/order_decorator.rb +++ b/app/models/spree/order_decorator.rb @@ -15,6 +15,7 @@ Spree::Order.class_eval do ship_address.address1 = distributor.pickup_address ship_address.city = distributor.city ship_address.zipcode = distributor.post_code + ship_address.state = distributor.state ship_address.country_id = distributor.country_id end end diff --git a/app/overrides/replace_delivery_addres.rb b/app/overrides/replace_delivery_addres.rb index 0798db7076..362e217bc0 100644 --- a/app/overrides/replace_delivery_addres.rb +++ b/app/overrides/replace_delivery_addres.rb @@ -1,5 +1,5 @@ -# Deface::Override.new(:virtual_path => "spree/checkout/_address", -# :replace => "[data-hook='shipping_fieldset_wrapper']", -# :partial => "spree/checkout/distributor", -# :name => "drop_off_point") +Deface::Override.new(:virtual_path => "spree/checkout/_address", + :replace => "[data-hook='shipping_fieldset_wrapper']", + :partial => "spree/checkout/distributor", + :name => "drop_off_point") diff --git a/app/views/spree/admin/distributors/_form.html.erb b/app/views/spree/admin/distributors/_form.html.erb index 62cd441cc9..d7db0cbbdb 100644 --- a/app/views/spree/admin/distributors/_form.html.erb +++ b/app/views/spree/admin/distributors/_form.html.erb @@ -40,6 +40,10 @@