Checkout

<%= form_for @order, :url => piggybak.orders_url, :method => "POST" do |f| %> <% if @order.errors.any? -%>
You have errors with your submission:
<%= raw @order.errors.full_messages.collect { |b| b.gsub(/^Line items payment/, 'Payment').gsub(/^Line items shipment shipping/, 'Shipping') }.join("
") %>
<% end -%>

User Details

<% if current_user -%> <%= f.label :email %> <%= f.text_field :email, { :readonly => true, :class => "readonly required" } %> or <%= link_to 'LOGOUT', destroy_user_session_path, :method => :delete, :class => "last" %> <% else -%> <%= f.label :email %> <%= f.text_field :email, :class =-> "required" %>
or <%= link_to 'LOG IN', new_user_session_path %> <% end -%>
<%= f.label :phone %> <%= f.text_field :phone, :class => "required" %>

Billing Address

<%= f.fields_for :billing_address do |billing_address| %> <%= render "address_form", :address => billing_address, :type => "billing" %> <% end -%>

Shipping Address copy from billing

<%= f.fields_for :shipping_address do |shipping_address| %> <%= render "address_form", :address => shipping_address, :type => "shipping" %> <% end -%>

Shipping Option

<%= f.fields_for :line_items, @order.line_items.detect { |li| li.line_item_type == "shipment" } do |line_item_f| %> <%= line_item_f.hidden_field :line_item_type, { :value => "shipment" } %> <%= line_item_f.fields_for :shipment do |shipment| %>
<%= shipment.label :shipping_method_id %> <%= shipment.select :shipping_method_id, [] %>
<% end -%> <% end -%>

Payment

<%= f.fields_for :line_items, @order.line_items.detect { |li| li.line_item_type == "payment" } do |line_item_f| %> <%= line_item_f.hidden_field :line_item_type, { :value => "payment" } %> <%= line_item_f.fields_for :payment do |payment| %>
<%= payment.label :number %> <% if @order.errors.keys.include?("payments.number".to_sym) %> <%= payment.text_field :number, :class => "required" %> <% else -%> <%= payment.text_field :number, :class => "required" %> <% end -%>
<%= payment.label :verification_value %> <% if @order.errors.keys.include?("payments.verification_value".to_sym) %> <%= payment.text_field :verification_value, :class => "required" %> <% else -%> <%= payment.text_field :verification_value, :class => "required" %> <% end -%>
<%= payment.label :month %> <% if @order.errors.keys.include?("payments.verification_value".to_sym) %> <%= payment.select :month, 1.upto(12).to_a %> / <%= payment.select :year, Time.now.year.upto(Time.now.year + 10).to_a %> <% else -%> <%= payment.select :month, 1.upto(12).to_a %> / <%= payment.select :year, Time.now.year.upto(Time.now.year + 10).to_a %> <% end -%>
<% end -%> <% end -%>
<%= f.submit %>
<% end -%>

Totals

<%= render "piggybak/cart/items", :page => "checkout" %>