Class: Refinery::Orders::LineItem

Inherits:
Core::BaseModel
  • Object
show all
Defined in:
app/models/refinery/orders/line_item.rb

Class Method Summary collapse

Class Method Details

.from_cart_item(item) ⇒ Object

validates :order_status, :presence => true, :uniqueness => true



12
13
14
15
16
17
18
19
# File 'app/models/refinery/orders/line_item.rb', line 12

def self.from_cart_item( item )
  return  self.create(
    :product    => item.product,
    :quantity   => item.quantity,
    :unit_price => item.price
  )

end

.has_digidownloads?(order_id) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
# File 'app/models/refinery/orders/line_item.rb', line 21

def self.has_digidownloads?( order_id )
  self.joins( :product, :digidownload ).
       where( 
             "\"refinery_line_items\".order_id = #{order_id}" +
             " AND \"refinery_products\".id =  \"refinery_line_items\".product_id" + 
               " AND \"refinery_digidownloads\".product_id = \"refinery_products\".id ").
       count > 0
end