Remove unnecessary conditions from out of stock query
In the query to get the number of out of stock products for the admin dashboard widget, it is not necessary to use `1=1` and also not necessary to use `posts.post_type IN ( 'product', 'product_variation' )` as only products are added to wp_wc_product_meta_lookup.
This commit is contained in:
parent
36cab83d76
commit
6e976c7f0c
|
@ -232,9 +232,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
|
|||
"SELECT COUNT( product_id )
|
||||
FROM {$wpdb->wc_product_meta_lookup} AS lookup
|
||||
INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID
|
||||
WHERE 1=1
|
||||
AND stock_quantity <= %d
|
||||
AND posts.post_type IN ( 'product', 'product_variation' )
|
||||
WHERE stock_quantity <= %d
|
||||
AND posts.post_status = 'publish'",
|
||||
$nostock
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue