Class: Comable::OrderItem

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Liquidable, Csvable, SkuChoice, SkuItem
Defined in:
app/models/comable/order_item.rb,
app/models/comable/order_item/csvable.rb

Defined Under Namespace

Modules: Csvable

Instance Method Summary collapse

Methods included from SkuChoice

#name_with_sku

Methods included from SkuItem

#sku_h?, #sku_v?

Instance Method Details

#completeObject



24
25
26
# File 'app/models/comable/order_item.rb', line 24

def complete
  # Nothing to do
end

#copy_attributesObject

TODO: カート投入時との差額表示



29
30
31
# File 'app/models/comable/order_item.rb', line 29

def copy_attributes
  self.attributes = current_attributes
end

#current_priceObject

時価を取得



34
35
36
# File 'app/models/comable/order_item.rb', line 34

def current_price
  variant.price
end

#current_subtotal_priceObject

時価小計を取得



39
40
41
# File 'app/models/comable/order_item.rb', line 39

def current_subtotal_price
  current_price * quantity
end

#sku_h_choice_nameObject



60
61
62
# File 'app/models/comable/order_item.rb', line 60

def sku_h_choice_name
  variant.option_values.first.try(:name)
end

#sku_h_item_nameObject



52
53
54
# File 'app/models/comable/order_item.rb', line 52

def sku_h_item_name
  product.option_types.first.try(:name)
end

#sku_v_choice_nameObject



64
65
66
# File 'app/models/comable/order_item.rb', line 64

def sku_v_choice_name
  variant.option_values.second.try(:name)
end

#sku_v_item_nameObject



56
57
58
# File 'app/models/comable/order_item.rb', line 56

def sku_v_item_name
  product.option_types.second.try(:name)
end

#stockObject



68
69
70
# File 'app/models/comable/order_item.rb', line 68

def stock
  variant.stocks.first
end

#stock=(stock) ⇒ Object



72
73
74
# File 'app/models/comable/order_item.rb', line 72

def stock=(stock)
  self.variant = stock.variant || stock.build_variant
end

#subtotal_priceObject

売価小計を取得



44
45
46
# File 'app/models/comable/order_item.rb', line 44

def subtotal_price
  price * quantity if price
end

#unstocked?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/models/comable/order_item.rb', line 48

def unstocked?
  !variant.can_supply? quantity
end