Class: Spree::WishedItem

Inherits:
Object
  • Object
show all
Extended by:
DisplayMoney
Defined in:
app/models/spree/wished_item.rb

Instance Method Summary collapse

Methods included from DisplayMoney

money_methods

Instance Method Details

#price(currency) ⇒ Object



32
33
34
# File 'app/models/spree/wished_item.rb', line 32

def price(currency)
  variant.amount_in(currency[:currency])
end

#total(currency) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'app/models/spree/wished_item.rb', line 36

def total(currency)
  variant_price = variant.amount_in(currency[:currency])

  if variant_price.nil?
    variant_price
  else
    quantity * variant_price
  end
end

#variant_id=(id) ⇒ Object

This is a workaround to allow the variant_id to be set with a prefixed ID in the API.

Parameters:

  • id (String)

    the prefixed ID of the variant



23
24
25
26
27
28
29
30
# File 'app/models/spree/wished_item.rb', line 23

def variant_id=(id)
  if id.to_s.include?('_')
    decoded = Spree::Variant.decode_prefixed_id(id)
    super(decoded)
  else
    super(id)
  end
end