wc_get_product_ids_on_sale()
Function that returns an array containing the IDs of the products that are on sale.
Хуков нет.
Возвращает
Массив
.
Использование
wc_get_product_ids_on_sale();
Список изменений
С версии 2.0 | Введена. |
Код wc_get_product_ids_on_sale() wc get product ids on sale WC 9.4.2
function wc_get_product_ids_on_sale() { // Load from cache. $product_ids_on_sale = get_transient( 'wc_products_onsale' ); // Valid cache found. if ( false !== $product_ids_on_sale ) { return $product_ids_on_sale; } $data_store = WC_Data_Store::load( 'product' ); $on_sale_products = $data_store->get_on_sale_products(); $product_ids_on_sale = wp_parse_id_list( array_merge( wp_list_pluck( $on_sale_products, 'id' ), array_diff( wp_list_pluck( $on_sale_products, 'parent_id' ), array( 0 ) ) ) ); set_transient( 'wc_products_onsale', $product_ids_on_sale, DAY_IN_SECONDS * 30 ); return $product_ids_on_sale; }