Class: Spree::Wishlist

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_by_param(param) ⇒ Object



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

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

Instance Method Details

#include?(variant_id) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#to_paramObject



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

def to_param
  token
end

#variant_idsArray<Integer>

returns the variant ids in the wishlist

Returns:

  • (Array<Integer>)


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

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)


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

def wished_items_count
  @wished_items_count ||= variant_ids.count
end