WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Admin\API

ProductsLowInStock::get_query() protected WC 1.0

Generate a query.

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

Хуков нет.

Возвращает

Строку.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_query( $siteside_only );
$siteside_only(true|false)
generates a query for sitewide low stock threshold only query.
По умолчанию: false

Код ProductsLowInStock::get_query() WC 5.7.1

protected function get_query( $siteside_only = false ) {
	global $wpdb;
	$query = "
		SELECT
			SQL_CALC_FOUND_ROWS wp_posts.*, 
			:postmeta_select
			wc_product_meta_lookup.stock_quantity
		FROM  
		  {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup
		  LEFT JOIN {$wpdb->posts} wp_posts ON wp_posts.ID = wc_product_meta_lookup.product_id 
		  :postmeta_join
		WHERE 
		  wp_posts.post_type IN ('product', 'product_variation') 
		  AND wp_posts.post_status = %s
		  AND wc_product_meta_lookup.stock_quantity IS NOT NULL 
		  AND wc_product_meta_lookup.stock_status IN('instock', 'outofstock') 
		  :postmeta_wheres
		order by wc_product_meta_lookup.product_id DESC   
		limit %d, %d
	";

	$postmeta = array(
		'select' => '',
		'join'   => '',
		'wheres' => 'AND wc_product_meta_lookup.stock_quantity <= %d',
	);

	if ( ! $siteside_only ) {
		$postmeta['select'] = 'meta.meta_value AS low_stock_amount,';
		$postmeta['join']   = "LEFT JOIN {$wpdb->postmeta} AS meta ON wp_posts.ID = meta.post_id 
		  AND meta.meta_key = '_low_stock_amount'";
		$postmeta['wheres'] = "AND (
		    (
		      meta.meta_value > '' 
		      AND wc_product_meta_lookup.stock_quantity <= CAST(
		        meta.meta_value AS SIGNED
		      )
		    ) 
		    OR (
		      (
		        meta.meta_value IS NULL 
		        OR meta.meta_value <= ''
		      ) 
		      AND wc_product_meta_lookup.stock_quantity <= %d
		    )
	    )";
	}

	return strtr(
		$query,
		array(
			':postmeta_select' => $postmeta['select'],
			':postmeta_join'   => $postmeta['join'],
			':postmeta_wheres' => $postmeta['wheres'],
		)
	);
}