Automattic\WooCommerce\Admin\API
ProductsLowInStock::get_products_without_custom_stock_threshold_count_query_str
Get a query string for products without a custom stock threshold.
Method of the class: ProductsLowInStock{}
No Hooks.
Returns
String.
Usage
// private - for code of main (parent) class only $result = $this->get_products_without_custom_stock_threshold_count_query_str();
ProductsLowInStock::get_products_without_custom_stock_threshold_count_query_str() ProductsLowInStock::get products without custom stock threshold count query str code WC 10.3.6
private function get_products_without_custom_stock_threshold_count_query_str() {
global $wpdb;
$query = $this->get_base_query(
array(
':selects' => 'count(*) as total',
':orderAndLimit' => '',
)
);
$postmeta = array(
'select' => 'meta.meta_value AS low_stock_amount,',
'join' => "LEFT JOIN {$wpdb->postmeta} AS meta ON wp_posts.ID = meta.post_id AND meta.meta_key = '_low_stock_amount' AND meta.meta_value > ''",
'wheres' => 'AND meta.post_id IS NULL AND wc_product_meta_lookup.stock_quantity <= %d',
);
return strtr(
$query,
array(
':postmeta_select' => $postmeta['select'],
':postmeta_join' => $postmeta['join'],
':postmeta_wheres' => $postmeta['wheres'],
)
);
}