WordPress at Your Fingertips
function is not described

WC_Product_Data_Store_CPT::read_stock_quantity() public WC 1.0

Re-reads stock from the DB ignoring changes.

{} It's a method of the class: WC_Product_Data_Store_CPT{}

No Hooks.

Return

null. Nothing.

Usage

$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT();
$WC_Product_Data_Store_CPT->read_stock_quantity( $product, $new_stock );
$product(WC_Product) (required) (passed by reference — &)
Product object.
$new_stock(int|float)
New stock level if already read.
Default: null

Code of WC_Product_Data_Store_CPT::read_stock_quantity() WC 5.8.0

public function read_stock_quantity( &$product, $new_stock = null ) {
	$object_read = $product->get_object_read();
	$product->set_object_read( false ); // This makes update of qty go directly to data- instead of changes-array of the product object (which is needed as the data should hold status of the object as it was read from the db).
	$product->set_stock_quantity( is_null( $new_stock ) ? get_post_meta( $product->get_id(), '_stock', true ) : $new_stock );
	$product->set_object_read( $object_read );
}