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



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

def subtotal
  price * quantity
end

#taxObject



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

def tax
  tax_exempt ? 0 : (subtotal * tax_rate).round(0).to_i
end

#totalObject



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

def total
  subtotal + tax
end