Created
March 22, 2012 22:13
-
-
Save losvedir/2165012 to your computer and use it in GitHub Desktop.
Convert delivery methods from radio buttons to select options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form.select :shipping_method, shipping_methods_for_select(@order) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @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