Skip to content

Instantly share code, notes, and snippets.

@xacaxulu
Created November 21, 2013 15:51
Show Gist options
  • Save xacaxulu/7584117 to your computer and use it in GitHub Desktop.
Save xacaxulu/7584117 to your computer and use it in GitHub Desktop.
<%
cost = product.product_costs.first
hide_qty ||= ''
unless cost.nil?
%>
<%= form_for :cart, :url => {:controller => "cart"}, :html => {:multipart => true, :class => "form", :id => "product_form"} do |form| %>
<% unless !hide_qty.blank? %>
<label><%= t :quantity %></label>
<select name="quantity">
<% min = cost.min_quantity.blank? ? 1 : cost.min_quantity %>
<% max = cost.max_quantity.blank? ? 20 : cost.max_quantity %>
<% (min..max).each do |i| %>
<option value="<%= i %>"><%= i %></option>
<% end %>
</select>
<% end %>
<%= hidden_field_tag 'product_id', product.id %>
<%= hidden_field_tag 'product_cost_id', cost.id %>
<%= submit_tag t(:add_to_cart), :class => "add-to-cart" %>
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment