Class: Spree::StockItem
Defined Under Namespace
Modules: Webhooks
Instance Method Summary
collapse
Methods included from Metadata
#metadata, #metadata=, #public_metadata=
Instance Method Details
#adjust_count_on_hand(value) ⇒ Object
45
46
47
48
49
|
# File 'app/models/spree/stock_item.rb', line 45
def adjust_count_on_hand(value)
with_lock do
set_count_on_hand(count_on_hand + value)
end
end
|
Tells whether it’s available to be included in a shipment
63
64
65
|
# File 'app/models/spree/stock_item.rb', line 63
def available?
in_stock? || backorderable?
end
|
#backordered_inventory_units ⇒ Object
58
59
60
|
# File 'app/models/spree/stock_item.rb', line 58
def in_stock?
count_on_hand > 0
end
|
#reduce_count_on_hand_to_zero ⇒ Object
67
68
69
|
# File 'app/models/spree/stock_item.rb', line 67
def reduce_count_on_hand_to_zero
set_count_on_hand(0) if count_on_hand > 0
end
|
#set_count_on_hand(value) ⇒ Object
51
52
53
54
55
56
|
# File 'app/models/spree/stock_item.rb', line 51
def set_count_on_hand(value)
self.count_on_hand = value
process_backorders(count_on_hand - count_on_hand_was)
save!
end
|