Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@losvedir
Created March 22, 2012 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save losvedir/2165012 to your computer and use it in GitHub Desktop.
Save losvedir/2165012 to your computer and use it in GitHub Desktop.
Convert delivery methods from radio buttons to select options
<%= form.select :shipping_method, shipping_methods_for_select(@order) %>
def shipping_methods_for_select(order)
order.rate_hash.each do |shipping_method|
content_tag(:option, "#{shipping_method[:name]} #{shipping_method[:cost]}", :value => shipping_method[:id])
end.join.html_safe
end
<% @order.rate_hash.each do |shipping_method| %>
<label>
<%= radio_button(:order, :shipping_method_id, shipping_method[:id]) %>
<% if Spree::Config[:shipment_inc_vat] %>
<%= shipping_method[:name] %> <%= format_price (1 + Spree::TaxRate.default) * shipping_method[:cost] %>
<% else %>
<%= shipping_method[:name] %> <%= number_to_currency shipping_method[:cost] %>
<% end %>
</label>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment