Automattic\WooCommerce\Admin\API\Reports\Stock\Stats
DataStore::get_count
Get count for the passed in stock status.
Method of the class: DataStore{}
No Hooks.
Returns
Int. Count.
Usage
// private - for code of main (parent) class only $result = $this->get_count( $status );
- $status(string) (required)
- Status slug.
DataStore::get_count() DataStore::get count code WC 10.3.5
private function get_count( $status ) {
global $wpdb;
return (int) $wpdb->get_var(
$wpdb->prepare(
"
SELECT count( DISTINCT posts.ID ) FROM {$wpdb->posts} posts
LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup ON posts.ID = wc_product_meta_lookup.product_id
WHERE posts.post_type IN ( 'product', 'product_variation' )
AND wc_product_meta_lookup.stock_status = %s
",
$status
)
);
}