Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added get directions link in retailer partial

  • Loading branch information...
commit 723ac06bd3be098f830fd2ebc16a438b7aca6052 1 parent dc8538d
@iloveitaly iloveitaly authored
View
16 app/helpers/spree/retailers_helper.rb
@@ -6,4 +6,20 @@ def state_nav_helper(retailers=[])
states.collect{|state| link_to(state, "##{state.downcase}") }.join(" | ").html_safe
end
+ def google_map_directions(address)
+ if address.class != String
+ address = [:address, :address2, :city, :state, :zipcode, :country].map {
+ |a| (address.respond_to? a) ? address.send(a) : ""
+ }.join " "
+ end
+
+ q = Rack::Utils::build_query({
+ :f => "q",
+ :hl => "en",
+ :saddr => "",
+ :daddr => address
+ })
+
+ "http://maps.google.com/maps?#{q}"
+ end
end
View
2  app/views/spree/retailers/_retailer.html.erb
@@ -33,6 +33,8 @@
<br/>
<%= link_to retailer.url, retailer.url, :class => 'popup' %>
<% end %>
+ <br/>
+ <%= link_to t(:get_directions), google_map_directions(retailer) %>
</p>
</div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.