Module: Spree::Core::ControllerHelpers::Order
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/spree/core/controller_helpers/order.rb
Instance Method Summary collapse
- #associate_user ⇒ Object
-
#current_order(options = {}) ⇒ Object
The current incomplete order from the token for use in cart and during checkout.
- #ip_address ⇒ Object
- #set_current_order ⇒ Object
-
#simple_current_order ⇒ Object
Used in the link_to_cart helper.
Instance Method Details
#associate_user ⇒ Object
48 49 50 51 52 53 |
# File 'lib/spree/core/controller_helpers/order.rb', line 48 def associate_user @order ||= current_order if try_spree_current_user && @order @order.associate_user!(try_spree_current_user) if @order.user.blank? || @order.email.blank? end end |
#current_order(options = {}) ⇒ Object
The current incomplete order from the token for use in cart and during checkout
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/spree/core/controller_helpers/order.rb', line 29 def current_order( = {}) [:create_order_if_necessary] ||= false if @current_order @current_order.last_ip_address = ip_address return @current_order end @current_order = find_order_by_token_or_user(, true) if [:create_order_if_necessary] && (@current_order.nil? || @current_order.completed?) @current_order = Spree::Order.create!(current_order_params) @current_order.associate_user! try_spree_current_user if try_spree_current_user @current_order.last_ip_address = ip_address end @current_order end |
#ip_address ⇒ Object
63 64 65 |
# File 'lib/spree/core/controller_helpers/order.rb', line 63 def ip_address request.remote_ip end |
#set_current_order ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/spree/core/controller_helpers/order.rb', line 55 def set_current_order if try_spree_current_user && current_order try_spree_current_user.orders.incomplete.where('id != ?', current_order.id).each do |order| current_order.merge!(order, try_spree_current_user) end end end |
#simple_current_order ⇒ Object
Used in the link_to_cart helper.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spree/core/controller_helpers/order.rb', line 15 def simple_current_order return @simple_current_order if @simple_current_order @simple_current_order = find_order_by_token_or_user if @simple_current_order @simple_current_order.last_ip_address = ip_address return @simple_current_order else @simple_current_order = Spree::Order.new end end |