WC_Product_Data_Store_CPT::read_stock_quantity()publicWC 1.0

Re-reads stock from the DB ignoring changes.

{} Это метод класса: WC_Product_Data_Store_CPT{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$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) (обязательный) (передается по ссылке — &)
Product object.
$new_stock(int|float)
New stock level if already read.
По умолчанию: null

Код WC_Product_Data_Store_CPT::read_stock_quantity() WC 6.4.1

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 );
}