Class: Spree::StockItem

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

Instance Method Summary collapse

Instance Method Details

#adjust_count_on_hand(value) ⇒ Object



24
25
26
27
28
29
30
# File 'app/models/spree/stock_item.rb', line 24

def adjust_count_on_hand(value)
  self.with_lock do
    self.reload
    self.update_attribute(:count_on_hand, self.count_on_hand + value)
    self.save!
  end
end

#available?Boolean

Tells whether it’s available to be included in a shipment

Returns:

  • (Boolean)


37
38
39
# File 'app/models/spree/stock_item.rb', line 37

def available?
  self.in_stock? || self.backorderable?
end

#backordered_inventory_unitsObject



16
17
18
# File 'app/models/spree/stock_item.rb', line 16

def backordered_inventory_units
  Spree::InventoryUnit.backordered_for_stock_item(self)
end

#in_stock?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/spree/stock_item.rb', line 32

def in_stock?
  self.count_on_hand > 0
end

#variant_nameObject



20
21
22
# File 'app/models/spree/stock_item.rb', line 20

def variant_name
  variant.name
end