Sha256: 86677c938d589b8abc3388f78e94c0077e099f38b8a8909177bb6ba14fd9bcdc

Contents?: true

Size: 445 Bytes

Versions: 2

Compression:

Stored size: 445 Bytes

Contents

class CartItem < ActiveRecord::Base
  belongs_to :product
  validates_associated :product

  belongs_to :cart
  validates_associated :cart

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

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

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

  def weight
    product.weight * quantity
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forgeos_commerce-1.9.1.rc1 app/models/cart_item.rb
forgeos_commerce-1.9.0 app/models/cart_item.rb