Module: Spree::Core::ControllerHelpers::Order Private

Extended by:
ActiveSupport::Concern
Includes:
Pricing
Defined in:
lib/spree/core/controller_helpers/order.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary (collapse)

Methods included from Pricing

#current_currency, #current_pricing_options

Instance Method Details

- (Object) associate_user

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
57
58
# File 'lib/spree/core/controller_helpers/order.rb', line 53

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

- (Object) current_order(options = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The current incomplete order from the guest_token for use in cart and during checkout



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/spree/core/controller_helpers/order.rb', line 32

def current_order(options = {})
  options[:create_order_if_necessary] ||= false

  return @current_order if @current_order

  @current_order = find_order_by_token_or_user(options, true)

  if options[:create_order_if_necessary] && (@current_order.nil? || @current_order.completed?)
    @current_order = Spree::Order.new(current_order_params)
    @current_order.user ||= try_spree_current_user
    # See issue https://github.com/spree/spree/issues/3346 for reasons why this line is here
    @current_order.created_by ||= try_spree_current_user
    @current_order.save!
  end

  if @current_order
    @current_order.last_ip_address = ip_address
    return @current_order
  end
end

- (Object) ip_address

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



68
69
70
# File 'lib/spree/core/controller_helpers/order.rb', line 68

def ip_address
  request.remote_ip
end

- (Object) set_current_order

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
63
64
65
66
# File 'lib/spree/core/controller_helpers/order.rb', line 60

def set_current_order
  if try_spree_current_user && current_order
    try_spree_current_user.orders.by_store(current_store).incomplete.where('id != ?', current_order.id).each do |order|
      current_order.merge!(order, try_spree_current_user)
    end
  end
end

- (Object) simple_current_order

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Used in the link_to_cart helper.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spree/core/controller_helpers/order.rb', line 18

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