mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
default states to current zone.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
5
db/migrate/20120409004831_add_state_to_distributor.rb
Normal file
5
db/migrate/20120409004831_add_state_to_distributor.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddStateToDistributor < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :distributors, :state_id, :integer
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user