<%= Spree.t(:account) %>

<%= f.label :email, Spree.t(:email) %> <% if can? :edit, @order.user %> <%= f.email_field :email, class: 'form-control' %> <% else %>

<%= @order.user.try(:email) || @order.email %>

<% end %>
<%= label_tag nil, Spree.t(:guest_checkout) %> <% if @order.completed? %>
<%= @order.user.nil? ? Spree.t(:say_yes) : Spree.t(:say_no) %>
<% else %> <% guest = @order.user.nil? %>
<%= label_tag :guest_checkout_true do %> <%= radio_button_tag :guest_checkout, true, guest %> <%= Spree.t(:say_yes) %> <% end %>
<%= label_tag :guest_checkout_false do %> <%= radio_button_tag :guest_checkout, false, !guest, disabled: @order.cart? %> <%= Spree.t(:say_no) %> <% end %>
<%= hidden_field_tag :user_id, @order.user_id %> <% end %>

<%= Spree.t(:billing_address) %>

<% if can? :edit, @order.user %> <%= f.fields_for :bill_address do |ba_form| %> <%= render partial: 'spree/admin/shared/address_form', locals: { f: ba_form, type: "billing" } %> <% end %> <% else %> <%= render partial: 'spree/admin/shared/address', locals: { address: @order.bill_address } %> <% end %>

<%= Spree.t(:shipping_address) %>

<% if can? :edit, @order.user %> <%= f.fields_for :ship_address do |sa_form| %>
<%= check_box_tag 'order[use_billing]', '1', ((@order.bill_address.empty? && @order.ship_address.empty?) && @order.bill_address.same_as?(@order.ship_address)) %> <%= label_tag 'order[use_billing]', Spree.t(:use_billing_address) %>
<%= render partial: 'spree/admin/shared/address_form', locals: { f: sa_form, type: 'shipping' } %> <% end %> <% else %> <%= render partial: 'spree/admin/shared/address', locals: { address: @order.ship_address } %> <% end %>
<% if can? :edit, @order.user %>
<%= button Spree.t('actions.update'), 'save' %>
<% end %>