Class: Spree::Wishlist

Inherits:
Object
  • Object
show all
Includes:
SingleStoreResource
Defined in:
app/models/spree/wishlist.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_by_param(param) ⇒ Object



45
46
47
# File 'app/models/spree/wishlist.rb', line 45

def self.get_by_param(param)
  find_by(token: param)
end

Instance Method Details

#include?(variant_id) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/spree/wishlist.rb', line 23

def include?(variant_id)
  wished_items.exists?(variant_id: variant_id)
end

#to_paramObject



27
28
29
# File 'app/models/spree/wishlist.rb', line 27

def to_param
  token
end

#variant_idsArray<Integer>

returns the variant ids in the wishlist

Returns:

  • (Array<Integer>)


41
42
43
# File 'app/models/spree/wishlist.rb', line 41

def variant_ids
  @variant_ids ||= wished_items.pluck(:variant_id)
end

#wished_items_countInteger

returns the number of wished items in the wishlist

Returns:

  • (Integer)


34
35
36
# File 'app/models/spree/wishlist.rb', line 34

def wished_items_count
  @wished_items_count ||= variant_ids.count
end