ProductStockStatus
in package
Enum class for all the product stock statuses.
Table of Contents
- IN_STOCK = 'instock'
- The product is in stock.
- LOW_STOCK = 'lowstock'
- The product is low in stock.
- ON_BACKORDER = 'onbackorder'
- The product is on backorder.
- OUT_OF_STOCK = 'outofstock'
- The product is out of stock.
- get_all() : array<string|int, string>
- Returns every stock status value defined by this enum, as a flat list.
Constants
IN_STOCK
The product is in stock.
public
string
IN_STOCK
= 'instock'
LOW_STOCK
The product is low in stock.
public
string
LOW_STOCK
= 'lowstock'
ON_BACKORDER
The product is on backorder.
public
string
ON_BACKORDER
= 'onbackorder'
OUT_OF_STOCK
The product is out of stock.
public
string
OUT_OF_STOCK
= 'outofstock'
Methods
get_all()
Returns every stock status value defined by this enum, as a flat list.
public
static get_all() : array<string|int, string>
It is wider than the set of statuses products store. self::LOW_STOCK is a reporting aggregate: the Analytics stock report counts in-stock products whose quantity has fallen to their low-stock threshold, so a low-stock product stores self::IN_STOCK. That report adds self::LOW_STOCK to its own enum for exactly that reason.
WC_Product::set_stock_status() coerces anything outside wc_get_product_stock_status_options() to self::IN_STOCK, so use that helper for values you intend to store or filter on. It returns a value => label map rather than a list, and being filterable it also carries statuses an extension added.
