Sha256: 930943ac0aa7f38dcfe38034a3a373a256c88ee1483ea7eb5c4b10de7e1b145c

Contents?: true

Size: 940 Bytes

Versions: 4

Compression:

Stored size: 940 Bytes

Contents

module Workarea
  decorate Storefront::OrdersController, with: :legacy_orders do
    def lookup
      order = LegacyOrder.lookup(params[:order_id], params[:postal_code])

      if order.present?
        session[:legacy_lookup_order_id] = order.id
        redirect_to order_path(order)
      else
        session[:legacy_lookup_order_id] = nil
        super
      end
    end

    def show
      if legacy_lookup_order.present? &&
        legacy_lookup_order.id.to_s.downcase == params[:id].to_s.downcase

        @order = Storefront::LegacyOrderViewModel.wrap(
          @legacy_lookup_order,
          view_model_options
        )

        render 'workarea/storefront/legacy_orders/show'
      else
        super
      end
    end

    private

    def legacy_lookup_order
      return nil unless session[:legacy_lookup_order_id].present?
      @legacy_lookup_order ||= LegacyOrder.find(session[:legacy_lookup_order_id])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-legacy_orders-2.0.3 app/controllers/workarea/storefront/orders_controller.decorator
workarea-legacy_orders-2.0.2 app/controllers/workarea/storefront/orders_controller.decorator
workarea-legacy_orders-2.0.1 app/controllers/workarea/storefront/orders_controller.decorator
workarea-legacy_orders-2.0.0 app/controllers/workarea/storefront/orders_controller.decorator