WordPress at Your Fingertips
function is not described

WC_Product_Data_Store_CPT::get_query_for_stock() public WC 1.0

Returns query statement for getting current _stock of a product.

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

No Hooks.


String|null. Query statement.


$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT();
$WC_Product_Data_Store_CPT->get_query_for_stock( $product_id );
$product_id(int) (required)
Product ID.

Code of WC_Product_Data_Store_CPT::get_query_for_stock() WC 5.7.1

public function get_query_for_stock( $product_id ) {
	global $wpdb;
	return $wpdb->prepare(
		SELECT COALESCE ( MAX( meta_value ), 0 ) FROM $wpdb->postmeta as meta_table
		WHERE meta_table.meta_key = '_stock'
		AND meta_table.post_id = %d