Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation
DownloadsWrapper::store_has_downloadable_products
See if the store has a downloadable product. This controls if we bother to show a preview in the editor.
Метод класса: DownloadsWrapper{}
Хуков нет.
Возвращает
true|false.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->store_has_downloadable_products();
Код DownloadsWrapper::store_has_downloadable_products() DownloadsWrapper::store has downloadable products WC 10.3.5
protected function store_has_downloadable_products() {
$has_downloadable_product = get_transient( 'wc_blocks_has_downloadable_product', false );
if ( false === $has_downloadable_product ) {
$product_ids = get_posts(
array(
'post_type' => 'product',
'numberposts' => 1,
'post_status' => 'publish',
'fields' => 'ids',
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'meta_query' => array(
array(
'key' => '_downloadable',
'value' => 'yes',
'compare' => '=',
),
),
)
);
$has_downloadable_product = ! empty( $product_ids );
set_transient( 'wc_blocks_has_downloadable_product', $has_downloadable_product ? '1' : '0', MONTH_IN_SECONDS );
}
return (bool) $has_downloadable_product;
}