WooCommerce Code Reference

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

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.

Tags
since
10.9.0
Return values
array<string|int, string> —