default states to current zone.

This commit is contained in:
Andrew Spinks
2012-04-22 12:10:35 +10:00
parent f075c50926
commit 48c6f4d7cc
6 changed files with 27 additions and 5 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -40,6 +40,10 @@
<td>Country: </td>
<td><%= f.collection_select(:country_id, @countries, :id, :name, :include_blank => true) %></td>
</tr>
<tr data-hook="pickup_state">
<td>State: </td>
<td><%= f.collection_select(:state_id, @distributor.country.states, :id, :name, :include_blank => true) %></td>
</tr>
<tr data-hook="pickup_times">
<td>Pickup times:</td>

View File

@@ -55,6 +55,11 @@
<%= @distributor.country.name if @distributor.country %>
</td>
</tr>
<th>Pickup state</th>
<td>
<%= @distributor.state.name if @distributor.state %>
</td>
</tr>
<th>Pickup times</th>
<td>

View File

@@ -0,0 +1,5 @@
class AddStateToDistributor < ActiveRecord::Migration
def change
add_column :distributors, :state_id, :integer
end
end