Automattic\WooCommerce\Admin\API
ProductsLowInStock::is_using_sitewide_stock_threshold_only
Check to see if store is using sitewide threshold only. Meaning that it does not have any custom stock threshold for a product.
Метод класса: ProductsLowInStock{}
Хуков нет.
Возвращает
true|false.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->is_using_sitewide_stock_threshold_only( $low_stock_threshold );
- $low_stock_threshold(int|null)
- Low stock threshold.
По умолчанию:null
Код ProductsLowInStock::is_using_sitewide_stock_threshold_only() ProductsLowInStock::is using sitewide stock threshold only WC 11.0.1
protected function is_using_sitewide_stock_threshold_only( $low_stock_threshold = null ) {
global $wpdb;
$query_string = "
select count(*) as total
from {$wpdb->postmeta}
where
meta_key='_low_stock_amount'
AND meta_value > ''
";
$args = array();
if ( $low_stock_threshold ) {
$query_string .= ' AND meta_value != %d';
$args[] = $low_stock_threshold;
}
// phpcs:ignore -- not sure why phpcs complains about this line when prepare() is used here.
$count = $wpdb->get_var( $wpdb->prepare( $query_string, $args ) );
return 0 === (int) $count;
}