Class: Effective::CartItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/cart_item.rb

Instance Method Summary collapse

Instance Method Details

#priceObject



19
20
21
22
23
24
25
26
# File 'app/models/effective/cart_item.rb', line 19

def price
  if (purchasable.price || 0).kind_of?(Integer)
    purchasable.price || 0
  else
    ActiveSupport::Deprecation.warn('price is a non-integer. It should be an Integer representing the number of cents.  Continuing with (price * 100.0).round(0).to_i conversion') unless EffectiveOrders.silence_deprecation_warnings
    (purchasable.price * 100.0).round(0).to_i rescue 0
  end
end

#subtotalObject Also known as: total



36
37
38
# File 'app/models/effective/cart_item.rb', line 36

def subtotal
  price * quantity
end

#tax_exemptObject



32
33
34
# File 'app/models/effective/cart_item.rb', line 32

def tax_exempt
  purchasable.try(:tax_exempt) || false
end

#titleObject



28
29
30
# File 'app/models/effective/cart_item.rb', line 28

def title
  purchasable.try(:title) || 'New Cart Item'
end