Skip to content

Commit

Permalink
Update stock items article after PR review
Browse files Browse the repository at this point in the history
This clarifies some information about `Spree::StockItem`s after a
review by kennyadsl. Specifically, it confirms how many `StockItem`s
should exist if there are multiple `StockLocation`s, and it details how
backorderable stock items are handled.
  • Loading branch information
benjaminwil committed Feb 14, 2018
1 parent 6b01a68 commit 9bc3811
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions guides/inventory/stock-items.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Stock items

On-hand inventory is tracked using the `Spree::StockItem` model. Each
`Spree::Variant` in a store has a corresponding `Spree::StockItem` object with a
`count_on_hand` value that represents the number of items you have in stock.
On-hand inventory is tracked using the `Spree::StockItem` model. A stock item
tracks stock at a single `Spree::StockLocation`.

If you only track stock at one stock location, then every `Spree::Variant` in
your store has one corresponding `Spree::StockItem` object. If you track stock
at two stock locations, then every `Spree::Variant` in your store has *two*
corresponding `Spree::StockItem`s: one for each `Spree::StockLocation`.

The `Spree::StockItem`'s `count_on_hand` value that represents the number of
items you have in stock.

`Spree::StockItem` objects have the following attributes:

Expand Down Expand Up @@ -32,10 +39,9 @@ While a `Spree::StockMovement` object logs the increase or decrease of the
`solidus_backend`.

Whenever an administrator updates the count on hand, they are discarding the old
value completely. So, if a stock item is
[backorderable](#backorderable-stock-items) and its `count_on_hand` is `-5`,
when the administrator changes the value to `20`, they are creating a
`Spree::StockMovement` with a value of `25`.
value completely. So, if a stock item's `count_on_hand` is `5`, when the
administrator changes the value to `20`, they are creating a
`Spree::StockMovement` with a value of `15`.

See the [Stock movements][stock-movements] article for more information.

Expand All @@ -45,4 +51,16 @@ See the [Stock movements][stock-movements] article for more information.

If a `Spree::StockItem` is `backorderable`, then customers can continue to order
it after the product is sold out. When a sold out product continues to sell, the
`count_on_hand` would become a negative integer.
`count_on_hand` becomes a negative integer.

For example, if a customer orders five backorderable items and its
`count_on_hand` becomes `-5`, the customer can still check out successfully.
[Inventory units][inventory-units] with the `state` value of `backordered` are
created for the five items.

The `Spree::Shipment`(s) associated with the backordered items cannot be shipped
until the stock has been replenished. Once the item is in stock again, each
backordered inventory unit's `state` value is changed from `backordered` to
`on_hand` and the shipment becomes shippable.

[inventory-units]: inventory-units.md

0 comments on commit 9bc3811

Please sign in to comment.