Sha256: 7839abe32398d15e85b295209b6b1b8f36f3146a9d00d1f1d7400d4244a266cc

Contents?: true

Size: 1.06 KB

Versions: 28

Compression:

Stored size: 1.06 KB

Contents

module Spree
  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 = 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 = 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

Version data entries

28 entries across 28 versions & 6 rubygems

Version Path
spree_core-0.70.7 lib/spree/current_order.rb
spree_core-0.70.6 lib/spree/current_order.rb
apispree_core-0.0.0 lib/spree/current_order.rb
My-Commerce_core-1.1.0 lib/spree/current_order.rb
My-Commerce_core-1.0.0 lib/spree/current_order.rb
MyCommerceapi-1.0.0 core/lib/spree/current_order.rb
MyCommerce-0.0.3 core/lib/spree/current_order.rb
rfcommerce_core-0.0.3 lib/spree/current_order.rb
spree_core-0.60.6 lib/spree/current_order.rb
spree_core-0.70.5 lib/spree/current_order.rb
spree_core-0.70.4 lib/spree/current_order.rb
spree_core-0.60.5 lib/spree/current_order.rb
spree_core-0.70.3 lib/spree/current_order.rb
spree_core-0.70.2 lib/spree/current_order.rb
spree_core-0.50.4 lib/spree/current_order.rb
spree_core-0.60.4 lib/spree/current_order.rb
spree_core-0.50.3 lib/spree/current_order.rb
spree_core-0.60.3 lib/spree/current_order.rb
spree_core-0.70.1 lib/spree/current_order.rb
spree_core-0.70.0 lib/spree/current_order.rb