%fieldset#shipping
  %ng-form{"ng-controller" => "ShippingCtrl", name: "shipping"}

    %h5{"ng-class" => "{valid: shipping.$valid, dirty: shipping.$dirty || submitted}"}
      %span.right
        %label.label.round.alert.right
          %i.ofn-i_009-close
        %label.label.round.success.right
          %i.ofn-i_051-check-big
      = t :checkout_shipping

    %accordion-group{"is-open" => "accordion.shipping",
      "ng-class" => "{valid: shipping.$valid, open: accordion.shipping}"}
      = render 'checkout/accordion_heading'

      .small-12.columns.medium-12.columns.large-6.columns
        %label{"ng-repeat" => "method in ShippingMethods.shipping_methods | orderBy: 'name'"}
          %input{type: :radio,
            required: true,
            name: "order.shipping_method_id",
            "ng-value" => "method.id",
            "ng-model" => "order.shipping_method_id"}
            {{ method.name }}
            %em.light{"ng-show" => "!method.price || method.price == 0"}
              = "(#{t(:checkout_method_free)})"
            %em.light{"ng-hide" => "!method.price || method.price == 0"}
              ({{ method.price | localizeCurrency }})

        %small.error.medium.input-text{"ng-show" => "!fieldValid('order.shipping_method_id')"}
          = "{{ fieldErrors('order.shipping_method_id') }}"

        %label{"ng-if" => "Checkout.requireShipAddress()"}
          %input{type: :checkbox, "ng-model" => "Checkout.ship_address_same_as_billing"}
          = t :checkout_address_same

        - if spree_current_user
          %label{"ng-if" => "Checkout.requireShipAddress()"}
            %input{type: :checkbox, "ng-model" => "Checkout.default_ship_address"}
            = t :checkout_default_ship_address

      .small-12.columns.medium-12.columns.large-6.columns
        #distributor_address.panel{"ng-show" => "Checkout.shippingMethod().description"}
          %span{ style: "white-space: pre-wrap;" }{{ Checkout.shippingMethod().description }}
          %br/
          %br/
          - if @order.order_cycle.pickup_time_for(@order.distributor)
            = t :checkout_ready_for
          = @order.order_cycle.pickup_time_for(@order.distributor)

      = f.fields_for :ship_address, @order.ship_address do |sa|
        = render 'checkout/shipping_ship_address'

      .row
        .small-12.columns
          = f.text_area :special_instructions, label: t(:checkout_instructions), size: "60x4", "ng-model" => "order.special_instructions"

      .row
        .small-12.columns.text-right
          %button.primary{"ng-disabled" => "shipping.$invalid", "ng-click" => "next($event)"}
            = t :next
