Class: Spree::StockItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::StockItem
- Defined in:
- app/models/spree/stock_item.rb
Instance Method Summary collapse
- #adjust_count_on_hand(value) ⇒ Object
-
#available? ⇒ Boolean
Tells whether it’s available to be included in a shipment.
- #backordered_inventory_units ⇒ Object
- #in_stock? ⇒ Boolean
- #variant_name ⇒ Object
Instance Method Details
#adjust_count_on_hand(value) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/models/spree/stock_item.rb', line 22 def adjust_count_on_hand(value) self.with_lock do self.count_on_hand = self.count_on_hand + value process_backorders if in_stock? self.save! end end |
#available? ⇒ Boolean
Tells whether it’s available to be included in a shipment
36 37 38 |
# File 'app/models/spree/stock_item.rb', line 36 def available? self.in_stock? || self.backorderable? end |
#backordered_inventory_units ⇒ Object
14 15 16 |
# File 'app/models/spree/stock_item.rb', line 14 def backordered_inventory_units Spree::InventoryUnit.backordered_for_stock_item(self) end |
#in_stock? ⇒ Boolean
31 32 33 |
# File 'app/models/spree/stock_item.rb', line 31 def in_stock? self.count_on_hand > 0 end |
#variant_name ⇒ Object
18 19 20 |
# File 'app/models/spree/stock_item.rb', line 18 def variant_name variant.name end |