Checkout

<%= form_for @order, :url => piggybak.order_submit_url, :method => "POST" do |f| %> <% if @order.errors.any? -%>
You have errors with your submission:
<%= raw @order.errors.full_messages.join("
") %>
<% end -%>

User Details

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

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 :shipments, f.object.shipments.build do |shipment| %>
<%= shipment.label :shipping_method_id %> <%= shipment.select :shipping_method_id, [] %>
<% end -%>

Payment

<%= f.fields_for :payments, f.object.payments.build do |payment| %>
<%= payment.label :number %> <% if @order.errors.keys.include?("payments.number".to_sym) %> <%= payment.text_field :number %> <% else -%> <%= payment.text_field :number %> <% end -%>
<%= payment.label :verification_value %> <% if @order.errors.keys.include?("payments.verification_value".to_sym) %> <%= payment.text_field :verification_value %> <% else -%> <%= payment.text_field :verification_value %> <% end -%>
<%= payment.label :month %> <% if @order.errors.keys.include?("payments.verification_value".to_sym) %> <%= payment.select :month, 1.upto(12) %> / <%= payment.select :year, Time.now.year.upto(Time.now.year + 10) %> <% else -%> <%= payment.select :month, 1.upto(12) %> / <%= payment.select :year, Time.now.year.upto(Time.now.year + 10) %> <% end -%>
<% end -%>
<%= f.submit %>
<% end -%>

Totals

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