Module: Spree::Core::ControllerHelpers::Order
- Extended by:
- ActiveSupport::Concern
- Includes:
- Pricing
- Defined in:
- app/helpers/spree/core/controller_helpers/order.rb
Instance Method Summary collapse
- #associate_user ⇒ Object
-
#current_order(options = {}) ⇒ Object
The current incomplete order from the guest_token for use in cart and during checkout.
- #ip_address ⇒ Object
- #set_current_order ⇒ Object
Methods included from Pricing
Instance Method Details
#associate_user ⇒ Object
37 38 39 40 41 42 |
# File 'app/helpers/spree/core/controller_helpers/order.rb', line 37 def associate_user @order ||= current_order if spree_current_user && @order && (@order.user.blank? || @order.email.blank?) @order.associate_user!(spree_current_user) end end |
#current_order(options = {}) ⇒ Object
The current incomplete order from the guest_token for use in cart and during checkout
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/spree/core/controller_helpers/order.rb', line 15 def current_order( = {}) should_create = [:create_order_if_necessary] || false should_build = [:build_order_if_necessary] || should_create return @current_order if @current_order @current_order = find_order_by_token_or_user(lock: [:lock]) if should_build && (@current_order.nil? || @current_order.completed?) @current_order = Spree::Order.new(new_order_params) @current_order.user ||= spree_current_user # See issue https://github.com/spree/spree/issues/3346 for reasons why this line is here @current_order.created_by ||= spree_current_user @current_order.save! if should_create end if @current_order @current_order.record_ip_address(ip_address) @current_order end end |
#ip_address ⇒ Object
52 53 54 |
# File 'app/helpers/spree/core/controller_helpers/order.rb', line 52 def ip_address request.remote_ip end |
#set_current_order ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/helpers/spree/core/controller_helpers/order.rb', line 44 def set_current_order if spree_current_user && current_order spree_current_user.orders.by_store(current_store).incomplete.where('id != ?', current_order.id).find_each do |order| current_order.merge!(order, spree_current_user) end end end |