Automattic\WooCommerce\Blocks
QueryFilters::generate_stock_status_count_query()
Generate calculate query by stock status.
Метод класса: QueryFilters{}
Хуков нет.
Возвращает
false|Строку
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->generate_stock_status_count_query( $status, $product_query_sql, $stock_status_options );
- $status(строка) (обязательный)
- status to calculate.
- $product_query_sql(строка) (обязательный)
- product query for current filter state.
- $stock_status_options(массив) (обязательный)
- available stock status options.
Код QueryFilters::generate_stock_status_count_query() QueryFilters::generate stock status count query WC 9.3.3
private function generate_stock_status_count_query( $status, $product_query_sql, $stock_status_options ) { if ( ! in_array( $status, $stock_status_options, true ) ) { return false; } global $wpdb; $status = esc_sql( $status ); return " SELECT COUNT( DISTINCT posts.ID ) as status_count FROM {$wpdb->posts} as posts INNER JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock_status' AND postmeta.meta_value = '{$status}' WHERE posts.ID IN ( {$product_query_sql} ) "; }