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

#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)


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

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



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

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