This repository has been archived by the owner on Apr 17, 2020. It is now read-only.
/
replace_billing.rb
150 lines (148 loc) · 5.62 KB
/
replace_billing.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
Deface::Override.new(:virtual_path => %q{spree/checkout/_address},
:name => %q{replace_billing},
:replace => %q{#billing[data-hook]},
:text => %q{<% content_for :javascripts do %>
<%= javascript_include_tag 'checkout', '/states' %>
<% end %>
<div id="content" role="content">
<h2>Your Billing Information</h2>
<%= form.fields_for :bill_address do |bill_form| %>
<div id="billing">
<ul class="inner fields">
<li class="half">
<%= bill_form.label :firstname, "First Name" %>
<%= bill_form.text_field :firstname %>
</li>
<li class="half last">
<%= bill_form.label :lastname, "Last Name" %>
<%= bill_form.text_field :lastname %>
</li>
<li>
<%= bill_form.label :address1, "Shipping address" %>
<%= bill_form.text_field :address1 %>
</li>
<li>
<%= bill_form.label :address2, "Shipping address 2" %>
<%= bill_form.text_field :address2 %>
</li>
<li>
<%= bill_form.label :city, "City" %>
<%= bill_form.text_field :city %>
</li>
<li class="half">
<%= bill_form.label :state, "State" %>
<span id="bstate">
<% have_states = !@order.bill_address.country.states.empty? %>
<noscript>
<%= bill_form.text_field :state_name, :class => 'required' %>
</noscript>
<% state_elements = [
bill_form.collection_select(:state_id, @order.bill_address.country.states,
:id, :name,
{:include_blank => true},
{:class => have_states ? "required" : "hidden",
:disabled => !have_states}) +
bill_form.text_field(:state_name,
:class => !have_states ? "required" : "hidden",
:disabled => have_states)
].join.gsub('"', "'").gsub("\n", "")
%>
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[
document.write("<%= raw state_elements %>");
// ]]>
</script>
</span>
</li>
<li class="half last">
<%= bill_form.label :zipcode, "Postal code" %>
<%= bill_form.text_field :zipcode %>
</li>
<li>
<%= bill_form.label :country_id, "Country" %>
<span id="bcountry">
<%= bill_form.collection_select :country_id, available_countries.uniq.sort, :id, :name %>
</span>
</li>
<li>
<%= bill_form.label :phone, "Phone" %>
<%= bill_form.text_field :phone %>
</li>
</ul>
</div>
<% end %>
<hr/>
<h2>Your Shipping Information</h2>
<%= form.fields_for :ship_address do |ship_form| %>
<div id="shipping">
<ul class="fields">
<li>
<%= check_box_tag 'order[use_billing]', '1', (!(@order.bill_address.empty? && @order.ship_address.empty?) && @order.bill_address.eql?(@order.ship_address)) %>
<label class="tick">Use my shipping address</label>
</li>
</ul>
<ul class="inner fields">
<li class="half">
<%= ship_form.label :firstname, "First Name" %>
<%= ship_form.text_field :firstname %>
</li>
<li class="half last">
<%= ship_form.label :lastname, "Last Name" %>
<%= ship_form.text_field :lastname %>
</li>
<li>
<%= ship_form.label :address1, "Shipping address" %>
<%= ship_form.text_field :address1 %>
</li>
<li>
<%= ship_form.label :address2, "Shipping address 2" %>
<%= ship_form.text_field :address2 %>
</li>
<li>
<%= ship_form.label :city, "City" %>
<%= ship_form.text_field :city %>
</li>
<li class="half">
<%= ship_form.label :state, "State" %>
<span id="sstate">
<% have_states = !@order.ship_address.country.states.empty? %>
<noscript>
<%= ship_form.text_field :state_name, :class => 'required' %>
</noscript>
<% state_elements = [
ship_form.collection_select(:state_id, @order.bill_address.country.states,
:id, :name,
{:include_blank => true},
{:class => have_states ? "required" : "hidden",
:disabled => !have_states}) +
ship_form.text_field(:state_name,
:class => !have_states ? "required" : "hidden",
:disabled => have_states)
].join.gsub('"', "'").gsub("\n", "")
%>
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[
document.write("<%= raw state_elements %>");
// ]]>
</script>
</span>
</li>
<li class="half last">
<%= ship_form.label :zipcode, "Postal code" %>
<%= ship_form.text_field :zipcode %>
</li>
<li>
<%= ship_form.label :country_id, "Country" %>
<span id="scountry">
<%= ship_form.collection_select :country_id, Spree::Country.all, :id, :name %>
</span>
</li>
<li>
<%= ship_form.label :phone, "Phone" %>
<%= ship_form.text_field :phone %>
</li>
</ul>
</div>
<% end %>
<div class="submit"><button type="submit" class="blue">Continue</button></div>
</div>})