Module: Spree::UserMethods

Extended by:
ActiveSupport::Concern
Includes:
RansackableAttributes, UserPaymentSource, UserReporting
Included in:
LegacyUser
Defined in:
app/models/concerns/spree/user_methods.rb

Instance Method Summary collapse

Methods included from UserReporting

#average_order_value, #lifetime_value, #order_count

Methods included from DisplayMoney

#money_methods

Instance Method Details

#analytics_idObject


42
43
44
# File 'app/models/concerns/spree/user_methods.rb', line 42

def analytics_id
  id
end

#has_spree_role?(role_in_question) ⇒ Boolean

has_spree_role? simply needs to return true or false whether a user has a role or not.

Returns:

  • (Boolean)

31
32
33
# File 'app/models/concerns/spree/user_methods.rb', line 31

def has_spree_role?(role_in_question)
  spree_roles.any? { |role| role.name == role_in_question.to_s }
end

#last_incomplete_spree_order(store) ⇒ Object


35
36
37
38
39
40
# File 'app/models/concerns/spree/user_methods.rb', line 35

def last_incomplete_spree_order(store)
  orders.where(store: store).incomplete.
    includes(line_items: [variant: [:images, :option_values, :product]]).
    order('created_at DESC').
    first
end

#total_available_store_creditObject


46
47
48
# File 'app/models/concerns/spree/user_methods.rb', line 46

def total_available_store_credit
  store_credits.reload.to_a.sum(&:amount_remaining)
end