Class: CartItem

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

Instance Method Summary collapse

Instance Method Details

#tax(options = {}) ⇒ Object



12
13
14
15
16
# File 'app/models/cart_item.rb', line 12

def tax(options = {})
  options = { :currency => true }.update(options.symbolize_keys)

  ("%01.2f" % (total(options) - total)).to_f
end

#total(options = {}) ⇒ Object



8
9
10
# File 'app/models/cart_item.rb', line 8

def total(options = {})
  product.price(options.update(:voucher_discount => false)) * quantity
end

#weightObject



18
19
20
# File 'app/models/cart_item.rb', line 18

def weight
  product.weight * quantity
end