Sha256: 56b352b03bc695ac78ebff5b77852cb357827daa2c2cfdb1eba41ea62f635dce

Contents?: true

Size: 1.15 KB

Versions: 15

Compression:

Stored size: 1.15 KB

Contents

module Spree
  module Core
    module CurrentOrder

      # This should be overridden by an auth-related extension which would then have the
      # opportunity to associate the new order with the # current user before saving.
      def before_save_new_order
      end

      # This should be overridden by an auth-related extension which would then have the
      # opporutnity to store tokens, etc. in the session # after saving.
      def after_save_new_order
      end

      # The current incomplete order from the session for use in cart and during checkout
      def current_order(create_order_if_necessary = false)
        return @current_order if @current_order
        if session[:order_id]
          @current_order = Spree::Order.find_by_id(session[:order_id], :include => :adjustments)
        end
        if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)
          @current_order = Spree::Order.new
          before_save_new_order
          @current_order.save!
          after_save_new_order
        end
        session[:order_id] = @current_order ? @current_order.id : nil
        @current_order
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spree_core-1.0.7 lib/spree/core/current_order.rb
spree_core-1.0.6 lib/spree/core/current_order.rb
spree_core-1.1.1 lib/spree/core/current_order.rb
spree_core-1.1.0 lib/spree/core/current_order.rb
spree_core-1.0.4 lib/spree/core/current_order.rb
spree_core-1.1.0.rc2 lib/spree/core/current_order.rb
spree_core-1.1.0.rc1 lib/spree/core/current_order.rb
spree_core-1.0.3 lib/spree/core/current_order.rb
spree_core-1.0.2 lib/spree/core/current_order.rb
spree_core-1.0.1 lib/spree/core/current_order.rb
spree_core-1.0.0 lib/spree/core/current_order.rb
spree_core-1.0.0.rc4 lib/spree/core/current_order.rb
spree_core-1.0.0.rc3 lib/spree/core/current_order.rb
spree_core-1.0.0.rc2 lib/spree/core/current_order.rb
spree_core-1.0.0.rc1 lib/spree/core/current_order.rb